Skip to content

Instantly share code, notes, and snippets.

@timshen91
Last active December 12, 2015 02:08
Show Gist options
  • Save timshen91/4696093 to your computer and use it in GitHub Desktop.
Save timshen91/4696093 to your computer and use it in GitHub Desktop.
(enum '((1 2) (3 4) (5 6))) ; => ((1 3 5) (1 3 6) (1 4 5) (1 4 6) (2 3 5) (2 3 6) (2 4 5) (2 4 6))
(define (enum a)
(cond ((null? a) '(()))
(else (apply append (map (lambda (x) (map (lambda (y) (cons x y)) (enum (cdr a)))) (car a))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment