Last active
December 22, 2015 05:08
-
-
Save sztamas/6421685 to your computer and use it in GitHub Desktop.
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
(defmacro product [xs dim] | |
"Creates a dim dimension cartesian product of the xs sequence. | |
For example (product \"ab\" 3) returns ((a a a) (b a a) (a b a) ...)" | |
(let [syms (take dim (repeatedly gensym)) | |
seq-expr (vec (interleave syms (repeat xs))) | |
body-expr (cons 'list syms)] | |
(list 'for seq-expr body-expr))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment