[Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Dougal Stanton
Are the functions 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 filter (passany tests) [0..10] filter (passall tests) [0..10] where tests = [5, odd] Or is there a

Re: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Neil Mitchell
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

Re: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Isaac Dupree
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 One thing I have

Re: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Dougal Stanton
On 17/01/2008, Stuart Cook [EMAIL PROTECTED] wrote: On Jan 18, 2008 1:46 AM, Isaac Dupree [EMAIL PROTECTED] wrote: nearly; using Prelude: passall ps v = all ($v) ps passany ps v = any ($v) ps Yes, thanks Isaac. That should have been obvious, argh... passall = swing all passany =

Re: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Stuart Cook
On Jan 18, 2008 1:46 AM, Isaac Dupree [EMAIL PROTECTED] 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:

Re[2]: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Bulat Ziganshin
Hello Isaac, Thursday, January 17, 2008, 5:46:20 PM, you wrote: yep, there's the idea of putting Bools in a typeclass that allows you to (||) functions-returning-Bool-class-instance for example, which I haven't used much but seems like a good idea (though potentially confusing, especially