The multipleLists
function needs to remove a given value from a list and return a list of lists. These sub lists group each element until it hits the value that needs to be removed. when this happens, a new sub list starts.
input: multipleLists 'b' "abcabc"
expected output: ["a","ca","c"]
actual output: ["a","c","a","c"]
input: multipleLists 1 [0,1,2,3,4,1,3,4]
expected output: [[0],[2,3,4],[3,4]]
actual output: [[0],[2],[3],[4],[3],[4]]
I think there is something wrong in the otherwise
case but I'm a bit stuck.
Here is my code:
multipleLists :: Eq a => a -> [a] -> [[a]]
multipleLists value list = case list of
[] -> []
[x] -> [[x]]
x:xs
| value == x -> multipleLists value xs
| otherwise -> [x] : (multipleLists value xs)