Powerset of collection in Clojure Similar to this question, here's another implementation. Assume the input is already a set.

 (defn powerset
       [set] 
       (reduce 
           (fn [xs x] (concat xs (map #(cons x %) xs)))
           [()] 
           set))
There isn't a whole lot here to comment on. I'll just mention a few things:


Technically, from my quick search of what a powerset is, this function should return sets. That seems petty, but unless it's documented to return a lazy list of lazy lists, users may try to treat the "subsets" as sets (like using them as functions). I'd finish this function off by mapping set over the list.
But to do that, you should rename your parameter, as you're shadowing the build-in set.
After doing the above two, it developed quite long lines and became nested. I'd add in some use of -&gt;&gt;, and put a few of the lines on the next line.


After that, I ended up with:

(defn powerset [base-set]
  (-&gt;&gt; base-set
       (reduce
         (fn [xs x] 
           (concat xs
                   (map #(cons x %) xs)))
         [()])

       (map set)))