Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fronx/1314822 to your computer and use it in GitHub Desktop.
Save fronx/1314822 to your computer and use it in GitHub Desktop.
;; fronx's solution to Power Set
;; https://4clojure.com/problem/85
(fn [s]
(let [bit-filter (fn [items mask]
(set
(keep-indexed
(fn [idx item]
(if (bit-test mask idx)
item))
items)))]
(set (for [mask (range 0 (Math/pow 2 (count s)))]
(bit-filter s mask)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment