[Haskell-beginners] \x -> x < 0.5 && x > -0.5

Carl Cravens raven at phoenyx.net
Mon Oct 19 22:19:41 EDT 2009


Michael Mossey wrote:
> Is there a nifty way to write
> 
> filter (\x -> x < 0.5 && x > -0.5) xs
> 
> without explicitly using x?

I'm pretty new to Haskell... are you looking for a *better* way to write this, or is this an exercise in exploring alternatives for the sake of understanding?

I'm not seeing any of the proposed alternatives as being as clear as the lambda function, and I'd be surprised (in my ignorance) if any of them were more efficient.

-- 
Carl D Cravens (raven at phoenyx.net)
Bad Command! Bad, Bad Command! Sit! Staaaaay...


More information about the Beginners mailing list