Skip to content

Instantly share code, notes, and snippets.

@candera
Created June 24, 2010 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save candera/451734 to your computer and use it in GitHub Desktop.
Save candera/451734 to your computer and use it in GitHub Desktop.
(defn cartes5
[a b & [c & ds :as more]]
(let [so-far
(for [x a y b]
[x y])]
(if more
(recur so-far c ds)
(map flatten so-far))))
@drcabana
Copy link

;; you got me thinking, how about...
(defn cross-prod [& colls](->> colls
%28reduce #%28for [x %1 y %2] [x y]%29%29
%28map flatten%29))

@candera
Copy link
Author

candera commented Jun 25, 2010

I love it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment