[Haskell-beginners] foldl' vs seq

Stephen Tetley stephen.tetley at gmail.com
Mon Feb 1 08:32:17 EST 2010

Hi Gabi

Furthermore, a bit of rewriting might make a better explanation.

Ignoring the seq, the right-hand side is:

fn (x:xs) = x + fn xs

Although the recursive step is the rightmost part, (fn xs) must return
back to (x + ...) to perform the summing. If the arguments are
swapped, the function is the same but the recursive step is obviously
not in the tail position:

fn (x:xs) = (fn xs) + x

Best wishes


More information about the Beginners mailing list