fork download
  1. ; snooker
  2.  
  3. (define (scan f a xs)
  4. (define (scanx f a xs)
  5. (if (null? xs) xs
  6. (scan f (f a (car xs)) (cdr xs))))
  7. (cons a (scanx f a xs)))
  8.  
  9. (define (copies n xs)
  10. (do ((n n (- n 1)) (ys (list) (append xs ys)))
  11. ((zero? n) ys)))
  12.  
  13. (define colors '(black pink blue brown green yellow red))
  14.  
  15. (define (points color) (length (member color colors)))
  16.  
  17. (define (scores xs) (cdr (scan + 0 (map points xs))))
  18.  
  19. (define perfect
  20. (append (copies 15 '(red black))
  21. '(yellow green brown blue pink black)))
  22.  
  23. (display (scores perfect)) (newline)
Success #stdin #stdout 0.02s 8184KB
stdin
Standard input is empty
stdout
(1 8 9 16 17 24 25 32 33 40 41 48 49 56 57 64 65 72 73 80 81 88 89 96 97 104 105 112 113 120 122 125 129 134 140 147)