Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subOneLists :: [a] -> [[a]]
- subOneLists ls = let helper :: [a] -> [a] -> [[a]] -> [[a]]
- helper _ [] ss = ss
- helper ps (x:xs) ss = helper ps' xs ss'
- where ps' = ps ++ [x]
- ss' = ss ++ [ps ++ xs]
- in helper [] ls []
- λ> subOneLists [1, 2, 3, 4]
- [[2,3,4],[1,3,4],[1,2,4],[1,2,3]]
- subOneLists :: [a] -> [[a]]
- subOneLists [] = []
- subOneLists (x:xs) = xs : map (x :) (subOneLists xs)
Add Comment
Please, Sign In to add comment