best performance with foldl

Hi all, for a benchmark I'd like to write code like this: foldl (+) [0 100000000] how do I get the best performance out of it? However, It is important for me to rely on a higher-order function. Is it possible to be en par with the C version? int64_t result = 0; for (int64_t i = 0; i <= 100000000; ++i) result += i; Many thanks in advance for helping out, Roland

Roland, in this case using the strict version of foldl' would give you
better performance, but to really reach C speed equivalence, I would check
out the vector package and read the stream fusion article.
Here is an example that fits your scenario:
https://gist.github.com/dmjio/6166076
On Sun, Oct 6, 2013 at 6:38 AM, Roland Leißa
Hi all,
for a benchmark I'd like to write code like this: foldl (+) [0 100000000]
how do I get the best performance out of it? However, It is important for me to rely on a higher-order function. Is it possible to be en par with the C version? int64_t result = 0; for (int64_t i = 0; i <= 100000000; ++i) result += i;
Many thanks in advance for helping out, Roland
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Cell: 1.630.740.8204
participants (2)
-
David Johnson
-
Roland Leißa