Skip to content

Instantly share code, notes, and snippets.

@Chouser
Forked from candera/cartesian-product.clj
Created June 24, 2010 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chouser/451752 to your computer and use it in GitHub Desktop.
Save Chouser/451752 to your computer and use it in GitHub Desktop.
(defn cartes4 [a b & [c & cs :as more]]
(let [so-far (for [x a, y b] [x y])]
(if more
(recur so-far c cs)
(map flatten so-far))))
(cartes4 [1 2 3] [9] [4 5] [6 7 8])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment