
22 Jun
2007
22 Jun
'07
3:52 p.m.
Neil Mitchell wrote:
Hi Michael,
You're wrong :)
foldr (||) False (repeat True)
Gives:
True
Remember that in Haskell everything is lazy, which means that the || short-circuits as soon as it can.
Thanks
Neil
Specifically it is graph reduced like this: or [F,T,F,F...] foldr (||) F [F,T,F,F...] F || foldr (||) F [T,F,F...] foldr (||) F [T,F,F...] T || foldr (||) F [F,F...] T The last line is because (T || _ = T) and lazyness