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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to