[Haskell-cafe] A probably-stupid question about a Prelude
implementation.
Philip Armstrong
phil at kantaka.co.uk
Fri Jun 22 11:43:45 EDT 2007
On Fri, Jun 22, 2007 at 11:31:17PM +0800, Michael T. Richter wrote:
> 1. Using foldr means I'll be traversing the whole list no matter what.
> This implies (perhaps for a good reason) that it can only work on a
> finite list.
foldr is lazy.
> Please tell me I'm wrong and that I'm missing something?
You are wrong and you're missing something :)
compare:
any ((==) 2) [1,2,3]
and
any ((==) 2) [1..]
any ((==) 0) [1..] will go _|_ of course.
Phil
--
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt
More information about the Haskell-Cafe
mailing list