News for hackers. Stuff that matters.
Re:It never makes sense to use foldl on lists in Haskell (2019) by Retric on Saturday March 21, 2020 @05:52AM (#22645544)
O(N) random reads and O(N) random inserts can quickly turn a wide rage of things to be compute bound. Creating a linked list from scratch via random insertions for example is an N^2 operation with surprisingly large constants.

Now sure, if it’s small and you’re only creating then reading it once then that’s fine. But, you’re assumptions need to be accurate or you just created a problem.

Re:It never makes sense to use foldl on lists in Haskell (2019) by fiddlerwoaroof on Saturday March 21, 2020 @01:49PM (#22648293)
In most of the cases where I’m using a list or array, I’m adding items to one end and then iterating forward over the structure a handful of times.

But, yeah, if you’re relying heavily on random access, pick a vector/array or some kind of tree/hash table.