Let\'s say I have the following data type
data Number = Positive Integer | Negative Integer
deriving (Eq, Show)
I have a function definiti
One way is pattern matching on the nested list to peek at the first element of the first list to figure out what you need to filter:
-- Note you could give this the more general type Eq a => [[a]] -> [[a]]
-- (as well as a more appropriate name)
removePos :: [[Number]] -> [[Number]]
removePos [] = [] -- Empty list case.
removePos xss@[[]:_] = xss -- If the first inner list is empty,
-- return the whole thing unchanged
removePos ((x:_):xss) = filter (notElem x) xss