[Haskell-cafe] Filter by several predicates at once

Stuart Cook scook0 at gmail.com
Thu Jan 17 10:01:41 EST 2008


On Jan 18, 2008 1:46 AM, Isaac Dupree <isaacdupree at charter.net> wrote:
> Neil Mitchell wrote:
> > 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
>
> nearly; using Prelude:
> passall ps v = all ($v) ps
> passany ps v = any ($v) ps

See also <http://haskell.org/haskellwiki/Pointfree#Swing>, which would
let you define

  passall = swing all
  passany = swing any

Whether that's any better than the pointwise version is up to you.


Stuart


More information about the Haskell-Cafe mailing list