Sharing Vector Structure in Haskell

Is Vector in the structure of a Haskell structure? In Clojure, changing (immutable) Vector only takes O (log n) time, because it is actually a three-like structure. ( http://hypirion.com/musings/understanding-persistent-vector-pt-1 )

Is there an equivalent implementation in Haskell?

+6
source share
1 answer

Data.Vector are simple arrays with O (n) modification.

At that time, there is no equivalent to the Clojure vector.

Data.Sequence is implemented as a finger tree and supports a wider range of asymptotically efficient operations than Clojure vector (O (log (n)) concatenation and splitting, O (1) read / write from both ends), but it is also a bit heavier structure data with a large amount of RAM usage and some fixed overhead.

+8
source

Source: https://habr.com/ru/post/973848/


All Articles