I have this function which removes occurrences of a given element within the list of lists.
remove :: Eq a => a -> [[a]] -> [[a]]
remove y [] = error "Can't remove an element from an empty list"
remove y xs = map (filter(/=y)) xs
How would I be able to do the same using List comprehension
Thank you
For each
linxs, addfilter (/= xs) lto the resulting list:or, removing filter by nesting comprehensions.
For each
xsinxssand for eachxinxs, keepxonly if it’s different fromy:It’s OK if you’re just practicing , but your version with
mapis way better 🙂