Skip to content

Instantly share code, notes, and snippets.

@egregius313
Last active March 9, 2017 15:46
Show Gist options
  • Save egregius313/83e055a8c1d723060f80455a0616ab30 to your computer and use it in GitHub Desktop.
Save egregius313/83e055a8c1d723060f80455a0616ab30 to your computer and use it in GitHub Desktop.
Basic implementation of cross product using reduce.
(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