Power set: Difference between revisions

→‎{{header|Haskell}}: Fixed mismatch between a function name and its type signature name, added a point-free formulation
(→‎{{header|Haskell}}: Fixed mismatch between a function name and its type signature name, added a point-free formulation)
Line 1,438:
or
<lang Haskell>powerSet :: [a] -> [[a]]
powersetpowerSet = foldr (\x acc -> acc ++ map (x:) acc) [[]]</lang>
 
which could also be understood, in point-free terms, as:
<lang haskell>powerSet :: [a] -> [[a]]
powerSet = foldr ((mappend <*>) . fmap . (:)) (pure [])</lang>
 
Examples:
 
9,659

edits