
14 Sep
2010
14 Sep
'10
10:40 p.m.
On Tue, Sep 14, 2010 at 6:26 PM, Klaus Gy
What should be the difference?
There's at least one big difference. 'secondSum' keeps the whole list in memory, because it only starts summing after it got to the tail of the list. This causes bad behaviour when the list doesn't need to be kept around: *Main> secondSum (replicate 1000000 0) 0 (32.34 secs, 503758400 bytes) *Main> firstSum 0 (replicate 1000000 0) 0 (0.98 secs, 243311272 bytes) Cheers! -- Felipe.