Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Structure sharing Vector in Haskell

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

Is there an equivalent implementation in Haskell?

like image 283
yong Avatar asked Aug 15 '14 01:08

yong


1 Answers

Data.Vector is plain arrays with O(n) modification.

At the time there is no equivalent of Clojure's vector.

Data.Sequence is implemented as a finger tree, and it supports a wider range of asymptotically efficient operations than Clojure's vector (O(log(n)) concatenation and splitting, O(1) read/write at both ends), but it's also a bit more heavyweight data structure with more RAM usage and some constant overheads.

like image 184
András Kovács Avatar answered Oct 02 '22 21:10

András Kovács