; 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)