fork(6) download
  1. (define (counts xs n)
  2. (let ((cs (make-vector (+ n 1) 0)))
  3. (vector-set! cs 0 1)
  4. (do ((xs xs (cdr xs)))
  5. ((null? xs) (vector-ref cs n))
  6. (do ((x (car xs) (+ x 1))) ((< n x))
  7. (vector-set! cs x (+ (vector-ref cs x)
  8. (vector-ref cs (- x (car xs)))))))))
  9.  
  10. (display (counts '(1 5 10 25 50) 100))
Success #stdin #stdout 0.02s 4176KB
stdin
Standard input is empty
stdout
292