Created
October 7, 2016 00:42
-
-
Save carld/c90b024b8dca0a51dbf7bbe40ddbe445 to your computer and use it in GitHub Desktop.
cartesian product of lists
This file contains hidden or 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 (product . args) | |
(if (null? args) | |
(list '()) | |
(apply append | |
(map (lambda (rest) | |
(map (lambda (first) | |
(cons first rest)) | |
(car args))) | |
(apply product (cdr args)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment