u-egi 4 months ago On my workstation running GHC 7.10.2, foldl' (\a e -> (mod e 10)*a) 1 [1..10^7] has a compiled run-time of 422 ms (all of it calculation) and allocates over 400 MBytes on the heap. Conversely, foldr (\e a -> (mod e 10)*a) 1 [1..10^7]
has a compiled run-time of 2203 ms (the same 422 ms calculation time
and 1781 ms of garbage collection) and allocates more than 550 MBytes on
the heap. That is what you should expect from reading the previous
sections; foldr will build up a huge stack of nested expression before evaluating the result and that stack needs to be garbage collected.
u-facafichciiiheihbb 4 months ago Prelude Data.List> fst $ foldl (\(!x,!y) !z -> (y, x+z)) (0,1) [1..10^8]
cabal: repl failed for fake-package-0. The build process was killed (i.e.
SIGKILL). The typical reason for this is that there is not enough memory
available (e.g. the OS killed a process using lots of memory).