
26 Jun
2005
26 Jun
'05
6:02 a.m.
Oops, somehow that reply by Scott Turner (which coincidentally
contained the same example) hadn't appeared for me yet :)
Anyway, seconded :)
On 26/06/05, Cale Gibbard
Well, the case of the built-in numeric types is somewhat different, but most functions automatically short circuit, since Haskell uses lazy evaluation.
For instance, it's perfectly okay to define myAnd = foldr (&&) True Note that this terminates on infinite lists which contain False as a value: myAnd (False : repeat True) will evaluate to False pretty much immediately.
- Cale