Adding scanl'

Henning Thielemann lemming at henning-thielemann.de
Wed Sep 12 14:49:54 CEST 2012


On Wed, 12 Sep 2012, Niklas Hambüchen wrote:

> On 11/09/12 22:23, Ben Millwood wrote:
>> if you compile with optimisations you may
>> find the memory leak goes away.
>
> Sure, but should users expect the space complexity being O(n) vs O(1)
> depending on a compiler switch?
>
> Was it intentional that sum is defined in terms of foldl and not foldl'?

I think yes, because (+) can be lazy, as Ben mentioned. Think of the sum 
of power series. Actually, foldl' would also work for power series, 
because it evaluates only the top-most constructor. This is also 
surprising. For me foldl' is quite a hack, since it relies on the hack 
'seq'.



More information about the Libraries mailing list