[Haskell-cafe] A probably-stupid question about a Prelude implementation.

Andrew Coppin andrewcoppin at btinternet.com
Fri Jun 22 15:13:33 EDT 2007


Chris Kuklewicz wrote:
> 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

I must sheepishly confess that I mistakenly throught that foldr would 
construct a chaint chain of ORs, which would then only be evaluated when 
it's returned.

Now I see why there's a strict version of foldl but *not* foldr... ;-)



More information about the Haskell-Cafe mailing list