Efficient heaps in purely functional languages

后端 未结 9 1906
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 13:42

As an exercise in Haskell, I\'m trying to implement heapsort. The heap is usually implemented as an array in imperative languages, but this would be hugely inefficient in purely

9条回答
  •  旧巷少年郎
    2021-01-30 13:56

    You could also use the ST monad, which allows you to write imperative code but expose a purely functional interface safely.

提交回复
热议问题