to write "map f (map g xs)" as a single call to map you could write
example xs = map (f.g) xs
but how would you write "filter p (filter q xs)" as a single call to filter? the dot operator doesnt seem to work for filter as it does for maps. guessing you'd use something else for predicates?
If you defined a function both
that looked like this:
both :: (a -> Bool) -> (a -> Bool) -> a -> Bool
both f g x = f x && g x
Then you could write:
example xs = filter (both p q) xs
I'm not sure if there's a standard function that does this for you...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With