I am trying to start learning haskell, and a question came up. Say, I have a function
countFilter :: (a -> Bool) -> [a] -> ([a], Int)
countFilter a z = case z of [] -> ([], 0);
(x:xs) -> (filter a z , length (filter a z))
It returns a list, all the items of which apply to a certain predicate and a length of that list, which is not relevant.
countFilter (<7) [1,2,4,7,11,8,2]
will output ([1,2,4,2], 4)
.
How to create such an output: ([7,11,8], 4)
using the same predicate (<7)?