diff --git a/math/powerlist/powerlist.hs b/math/powerlist/powerlist.hs new file mode 100644 index 0000000..9e2e85b --- /dev/null +++ b/math/powerlist/powerlist.hs @@ -0,0 +1,12 @@ +powerlist l + | l == [] = [[]] + | otherwise = (powerlist (tail l)) ++ + (map (\x -> (head l):x) (powerlist (tail l))) + + +{- open shell and enter: + ghci + :load powerlist.hs + powerlist [1,2,3] + + Should return: [[],[3],[2],[2,3],[1],[1,3],[1,2],[1,2,3]] -} \ No newline at end of file