; snooker
(define (scan f a xs)
(define (scanx f a xs)
(if (null? xs) xs
(scan f (f a (car xs)) (cdr xs))))
(cons a (scanx f a xs)))
(define (copies n xs)
(do ((n n (- n 1)) (ys (list) (append xs ys)))
((zero? n) ys)))
(define colors '(black pink blue brown green yellow red))
(define (points color) (length (member color colors)))
(define (scores xs) (cdr (scan + 0 (map points xs))))
(define perfect
(append (copies 15 '(red black))
'(yellow green brown blue pink black)))
(display (scores perfect)) (newline)
OyBzbm9va2VyCgooZGVmaW5lIChzY2FuIGYgYSB4cykKICAoZGVmaW5lIChzY2FueCBmIGEgeHMpCiAgICAoaWYgKG51bGw/IHhzKSB4cwogICAgICAoc2NhbiBmIChmIGEgKGNhciB4cykpIChjZHIgeHMpKSkpCiAgKGNvbnMgYSAoc2NhbnggZiBhIHhzKSkpCgooZGVmaW5lIChjb3BpZXMgbiB4cykKICAoZG8gKChuIG4gKC0gbiAxKSkgKHlzIChsaXN0KSAoYXBwZW5kIHhzIHlzKSkpCiAgICAgICgoemVybz8gbikgeXMpKSkKCihkZWZpbmUgY29sb3JzICcoYmxhY2sgcGluayBibHVlIGJyb3duIGdyZWVuIHllbGxvdyByZWQpKQoKKGRlZmluZSAocG9pbnRzIGNvbG9yKSAobGVuZ3RoIChtZW1iZXIgY29sb3IgY29sb3JzKSkpCgooZGVmaW5lIChzY29yZXMgeHMpIChjZHIgKHNjYW4gKyAwIChtYXAgcG9pbnRzIHhzKSkpKQoKKGRlZmluZSBwZXJmZWN0CiAgKGFwcGVuZCAoY29waWVzIDE1ICcocmVkIGJsYWNrKSkKICAgICAgICAgICcoeWVsbG93IGdyZWVuIGJyb3duIGJsdWUgcGluayBibGFjaykpKQoKKGRpc3BsYXkgKHNjb3JlcyBwZXJmZWN0KSkgKG5ld2xpbmUp