Last active
March 9, 2017 15:46
-
-
Save egregius313/83e055a8c1d723060f80455a0616ab30 to your computer and use it in GitHub Desktop.
Basic implementation of cross product using reduce.
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
(defn product [a & bs] | |
"The cross product of sets." | |
(reduce | |
(fn [xss ys] | |
(mapcat (fn [xs] (map (partial conj xs) ys)) xss)) | |
(map vector a) | |
bs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment