Im trying to define the filter function. Based on the function's definition, the filter' function is a function (say help function to differ from the main filter' function) that takes in a function and a list to give a list. The help function takes in a variable and gives back a Bool value. But according the line 4, the help function evaluates a along with [x] to give a Bool Value which then finally gives back a list.
So can I understand the help function as a function that takes in a and [a] to give a Bool value. The main filter' function then takes in this Bool value to give back a list?
Im aware that the function's definition does not suggest this but it's kinda logical based on the code. Thanks
filter' :: (a -> Bool) -> [a] -> [a]
filter' _ [] = []
filter' a (x:xs)
| a x == True = x:filter' a xs
| otherwise = filter' a xs
filter'isfilter. This is just a straightforward recursive function, withfilter'calling itself on the tail of its list input.filter.filter'is used to distinguish it from the realfilter.a, which is the predicate passed tofilter.