[Haskell-cafe] A guess on stack-overflows - thunks build-up and
Bas van Dijk
v.dijk.bas at gmail.com
Fri Mar 20 08:40:37 EDT 2009
On Fri, Mar 20, 2009 at 11:59 AM, GüŸnther Schmidt <gue.schmidt at web.de> wrote:
> I apparently can have a huge thunk build up eventhough I use a supposedly
> accumulative, tail-recursive algorithm.
This is correct. If you don't strictly evaluate your accumulator
before you tail recursive, a thunk will build up. See the tail
recursive foldl for example in:
This is why you probably always need the strict foldl' instead of foldl.
More information about the Haskell-Cafe