I would like to remove all occurrences of a given value from within a list of lists. For example, input:
'a' ["abc", "bc", "aa"]
output:
["bc", "bc", ""]
so far:
remove :: Eq a => a -> [[a ]] -> [[a ]]
remove y xs = filter(\x -> x/= y) xs
I'm getting an error, thank you in advance.
You need to map over the outer lists.
remove y xs = map (filter(\x -> x/= y)) xs
You don't actually need a lambda here, nicer:
remove y xs = map (filter(/=y)) xs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With