Skip to content

Instantly share code, notes, and snippets.

@rjacuna
Created October 6, 2018 09:30
Show Gist options
  • Save rjacuna/31ed8b25b986fb6e6feef8387ae89eb8 to your computer and use it in GitHub Desktop.
Save rjacuna/31ed8b25b986fb6e6feef8387ae89eb8 to your computer and use it in GitHub Desktop.
Powerset
(defn powerset [X]
(let [n (count X)]
(->> (range (inc n))
(map #(clojure.math.combinatorics/combinations (vec X) %))/
(apply concat)
(map set)
(into #{}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment