【发布时间】:2014-08-15 01:28:41
【问题描述】:
Haskell 结构中的Vector 是共享的吗?在 Clojure 中,修改(不可变的)vector 只需要 O(log n) 时间,因为它实际上是一个类似 trie 的结构。 (http://hypirion.com/musings/understanding-persistent-vector-pt-1)
Haskell 中是否有等效的实现?
【问题讨论】:
-
vector库是用数组实现的,具有优化组合向量操作的巧妙规则,并提供了类似列表的 API。正如您对函数式语言所期望的那样,许多 haskell 数据结构都建立在不同种类的树上,但我不知道具体的结构。 -
看看
Data.Sequencehttp://hackage.haskell.org/package/containers-0.2.0.1/docs/Data-Sequence.html