[Haskell-cafe] Re: powerSet = filterM (const [True,
False]) ... is this obfuscated haskell?
Gleb Alexeyev
gleb.alexeev at gmail.com
Fri Jul 17 07:00:40 EDT 2009
On Jul 17, 2009 1:40pm, Thomas Hartman wrote:
> my question to all 3 (so far) respondants is, how does your
>
> explanation explain that the result is the power set?
>
>
I guess you forgot to reply to the cafe.
Well, to me the modified definition I posted looks like the essence of
powerset, the set of all subsets. Every element x of the input list
divides the powerset in 2 halves, the first one contains x, the second
one doesn't. Filtering on the non-deterministic predicate (\x -> return
True `mplus` return False) in the List monad does exactly that.
More information about the Haskell-Cafe
mailing list