I understand that the Haskell filter is a high-order function (which means a function that takes another function as a parameter) that goes through a list that checks which element fulfills a certain Boolean condition.
I do not quite understand its definition:
filter:: (a->Bool)->[a]->[a]
filter p [] = []
filter p (x:y) | p x = x:filter p y
| otherwise = filter p y
I understand that if I pass an empty list of functions, it will simply return an empty list, but how do I read the last two lines?
source
share