Fwd: [Haskell-cafe] curious about sum
Jochem Berndsen
jochem at functor.nl
Sun Jun 14 15:23:00 EDT 2009
Alberto G. Corona wrote:
> Once more I forgot to send my messages to the haskell cafe list. All the
> rest of the list which I´m suscribed to, send the mail replies to the list
> automatically, but this doesn´t. Please, can this be changed?.
This comes up every so often, but I would be against this. Your e-mail
client should support mailing lists.
> this version of foldl IS strict:
>
> foldlStrict f z0 xs0 = lgo z0 xs0
> where
> lgo z [] = z
> lgo z (x:xs) =let t= f z x in t `seq` lgo t xs
>
> main= print $ foldlStrict (+) 0 [1..1000000]
> 500000500000
>
> so the garbage collector do the job in freeing the consumed part of the
> list
This is correct; the function you defined is equivalent to foldl' in
Data.List, if I'm not mistaken.
Regards,
--
Jochem Berndsen | jochem at functor.nl
GPG: 0xE6FABFAB
More information about the Haskell-Cafe
mailing list