Anonymous user
Power set: Difference between revisions
→{{header|Haskell}}: removed nowiki tags inside code
(→{{header|Haskell}}: removed nowiki tags inside code) |
|||
Line 549:
powerset = fromList . fmap fromList . listPowerset . toList
listPowerset :: [a] ->
listPowerset = filterM (const [True, False])</lang>
<tt>listPowerset</tt> describes the result as all possible (using the list monad) filterings (using <tt>filterM</tt>) of the input list, regardless (using <tt>const</tt>) of each item's value. <tt>powerset</tt> simply converts the input and output from lists to sets.
|