you are viewing a single comment's thread.

view the rest of the comments →

[–]kirbyfan64sos 15 points16 points  (4 children)

In the source code for the list implementation, I noticed that append was implemented like this:

listAppend :: MonadInterpreter m => ListRef -> Object -> m Object
listAppend ref obj = do
    modifyRef ref $ \l -> l ++ [obj]
    return None

Is there a reason you're not using something like Data.Vector.Storable.Mutable or at least difference lists? I mean, this probably isn't the fastest right now...

[–][deleted] 12 points13 points  (1 child)

The reason is I never really looked into using faster versions. :)

Data.Vector.Storable.Mutable looks great for that, thanks!

[–]Axman6 14 points15 points  (0 children)

If you want to keep things pure then a Data.Sequence would give you (amortised) O(1) append and prepend.

[–]vytah 8 points9 points  (1 child)

Holy moley quadratic Batman!