Speeding up Data.List.inits

David Feuer david.feuer at gmail.com
Sat Jul 19 08:45:01 UTC 2014


I don't really see how recursing into some other inits function would help.
The same laziness requirement should hold everywhere:

take (n+1) $ inits ([1 .. n] ++ undefined)  =  inits [1 .. n]

Maybe I don't understand what you mean properly.


On Sat, Jul 19, 2014 at 4:29 AM, Henning Thielemann <
schlepptop at henning-thielemann.de> wrote:

> Am 19.07.2014 10:25, schrieb David Feuer:
>
>  I'm not sure about the theory of it, but if I load the module in GHCi
>> and run
>> head $ last $ initsR [0..100000::Int]
>> I get a response *immediately*.
>> If I run
>> head $ last $ initsDL [0..100000::Int]
>> I wrote this email while waiting for that to complete, and gave up on
>> it. There may be an asymptotic performance bug here.
>>
>
> Sorry, I got the implementation of initsDL wrong (recursed into the wrong
> inits-function).
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140719/5cc26c17/attachment.html>


More information about the Libraries mailing list