I am trying to write a Haskell function which takes a list
ls and returns all sub-lists obtained by removing one element from
ls. An additional constraint is that the returned list of lists must be in the order of the missing element.
Here is what I have. I know there must be a simpler solution.
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]]