foldl, tail recursion, and strictness (was: stack overflow)

Ketil Malde ketil@ii.uib.no
26 Feb 2001 15:57:14 +0100


"C.Reinke" <C.Reinke@ukc.ac.uk> writes:

> So foldl is indeed tail recursive, but this doesn't help if its
> operator isn't strict because the tail recursion only builds up the
> expression to be evaluated. Making strictness explicit by defining a
> variant of foldl that evaluates its accumulator at each step helps to
> solve the problem and documents programmer intentions.

> This is quite common a trap for Haskellers to fall into

It makes me wonder if it's common enough that strict foldl should be
the default?  Are there (many) cases where a partial foldl makes
sense?

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants