Re: foldl, tail recursion, and strictness (was: stack overflow)
26 Feb
2001
26 Feb
'01
2:57 p.m.
"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
9314
Age (days ago)
9314
Last active (days ago)
0 comments
1 participants
participants (1)
-
Ketil Malde