fork(1) download
  1. (define (p n list)
  2. (cond ((< n 0) 0)
  3. ((= n 0) 1)
  4. ((and (< 0 n) (null? list)) 0)
  5. (else
  6. (sum (lambda (i) (* (c n i) (p (- n i) (cdr list)))) 0 (lambda (x) (+ x 1)) (car list)))))
  7.  
  8.  
  9. (define (f m n)
  10. (if (= n 0)
  11. 1
  12. (* m (f (- m 1) (- n 1)))))
  13.  
  14. (define (c m n)
  15. (if (< m n)
  16. 0
  17. (let ((l (- m n)))
  18. (if (< l n)
  19. (quotient (f m l) (f l l))
  20. (quotient (f m n) (f n n))))))
  21.  
  22. (define (sum term a next b)
  23. (if (> a b)
  24. 0
  25. (+ (term a)
  26. (sum term (next a) next b))))
  27.  
  28. (print (p 12 (list 6 4 4 4 3 3 3)))
Success #stdin #stdout 0.15s 9052KB
stdin
Standard input is empty
stdout
9839773020