defn combinations items let size count items if size set items if map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(defn combinations
[items r]
(let [size (count items)]
(if (= r size)
[ (set items) ]
(if (= 1 r)
(map #(set [%]) items)
(let [fst #{ (first items) } rst (rest items)]
(concat
(map #(union fst %) (combinations rst (dec r)))
(combinations rst r)))))))