(defn combinations [& cs]
(reduce (fn [vs c]
(mapcat #(map conj vs (repeat %)) c))
[[]] cs))
Saturday, October 18, 2008
Clojure Golf: combinations
This post has moved,
go to its new location
Subscribe to:
Post Comments (Atom)
When the pupil is ready to learn, a teacher will appear.
(defn combinations [& cs]
(reduce (fn [vs c]
(mapcat #(map conj vs (repeat %)) c))
[[]] cs))
1 comment:
Nice. Glad to see you back!
Post a Comment