[Haskell-cafe] Filter by several predicates at once

Neil Mitchell ndmitchell at gmail.com
Thu Jan 17 09:27:39 EST 2008


Hi

> > passall, passany :: [a -> Bool] -> a -> Bool
> > passall ps v = and $ map ($v) ps
> > passany ps v = or $ map ($v) ps
>
> or something similar defined anywhere? Such that one can write

Don't think so.

One thing I have often wanted is something like:

or1 a b x = a x || b x
or2 a b x y = a x y || b x y

Then you can do:

filter ((>5) `or1` odd) [0..10]
filter ((>5) `and1` odd) [0..10]

You can imagine that or1 could get a symbol such as ||#, and or2 could
perhaps be ||## (if # wasn't already really overloaded)

Thanks

Neil


More information about the Haskell-Cafe mailing list