Guest User

Untitled

a guest
Nov 13th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. subOneLists :: [a] -> [[a]]
  2. subOneLists ls = let helper :: [a] -> [a] -> [[a]] -> [[a]]
  3. helper _ [] ss = ss
  4. helper ps (x:xs) ss = helper ps' xs ss'
  5. where ps' = ps ++ [x]
  6. ss' = ss ++ [ps ++ xs]
  7. in helper [] ls []
  8.  
  9. λ> subOneLists [1, 2, 3, 4]
  10. [[2,3,4],[1,3,4],[1,2,4],[1,2,3]]
  11.  
  12. subOneLists :: [a] -> [[a]]
  13. subOneLists [] = []
  14. subOneLists (x:xs) = xs : map (x :) (subOneLists xs)
Add Comment
Please, Sign In to add comment