Skip to content

Instantly share code, notes, and snippets.

@candera
Created June 24, 2010 17:58
Show Gist options
  • 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