I'm trying to figure out how to negate the results of two parameter boolean function like not . any
. I understand why it didn't work by breaking it down as shown below, but I'm not sure how to write a function that does this elegantly. I managed to do curry $ not . uncurry any
Prelude> :t not
not :: Bool -> Bool
Prelude> :t any
any :: Foldable t => (a -> Bool) -> t a -> Bool
Prelude> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
curry $ not . uncurry any
:: Foldable t => (a -> Bool) -> t a -> Bool
There is a standard point-free-ifier, available standalone or via lambdabot, which gives:
18:02 <dmwit> ?pl \f xs -> any (\x -> not (f x)) xs
18:02 <lambdabot> any . (not .)
18:04 <dmwit> ?pl \f xs -> not (any f xs)
18:04 <lambdabot> (not .) . any
There are many ways to spell this general operation.
Edit: Thanks to zudov for the following suggested extra text: You can also access pointfree
tool by installing pointfree
or using one of web interfaces (e.g. http://pointfree.io).
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