[Haskell-cafe] definition of sum

Don Stewart dons at galois.com
Wed Mar 10 16:48:27 EST 2010

> After programming as an exercice the sum function, my version is
> faster than the Data.List's version. Looking at the source code,
> Data.List uses a foldl and not a foldl'. foldl' seems faster and
> allows to use very big lists. So, why is foldl used by Data.List for
> sum?

It's considered a bug in the H98 report I think (since there was no
fold' at the time).

If you're summing sequences, have a look at Data.Vector for faster code.

More information about the Haskell-Cafe mailing list