3 ms·
Due to data immutability, a lot of the standard data structures in Haskell are quite interesting. Eg `Data.Sequence` (https://hackage.haskell.org/package/conta
by fho 4y ago
Due to data immutability, a lot of the standard data structures in Haskell are quite interesting.
Eg `Data.Sequence` (https://hackage.haskell.org/package/containers-0.6.5.1/docs/Data-Sequence.html https://hackage.haskell.org/package/containers-0.6.5.1/docs/...) is based on Finger Trees (http://staff.city.ac.uk/~ross/papers/FingerTree.html http://staff.city.ac.uk/~ross/papers/FingerTree.html) which allow
O(log(min(i,n-i))) inserts (at i) and O(1) inserts at the beginning or end even thou the data structure is basically copy-on-write.
In general Haskell gas a lot of specialized data structures. On of my favorites is `Data.IntMap` (https://hackage.haskell.org/package/containers-0.6.5.1/docs/Data-IntMap-Lazy.html https://hackage.haskell.org/package/containers-0.6.5.1/docs/...) which is a specialized map for integer keys (based on Patricia trees iirc).
(Man I miss working in Haskell :-( )