Last active
May 24, 2019 02:48
-
-
Save ldcc/00e9164840530a5ac18bd2e31b1b79a4 to your computer and use it in GitHub Desktop.
Computes all combinations of r elements from n.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define combo | |
(let ([d (- n r)]) | |
(λ (n r) | |
(/ (factorial n 1) | |
(factorial r 1) | |
(factorial d 1))))) | |
(define factorial | |
(λ (x s) | |
(cond [(< x 1) s] | |
[else | |
(factorial | |
(- x 1) | |
(* x s))]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment