Created
October 6, 2018 09:30
-
-
Save rjacuna/31ed8b25b986fb6e6feef8387ae89eb8 to your computer and use it in GitHub Desktop.
Powerset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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