Haskell shying away from probabilistic data structures?

前端 未结 7 1017
时光说笑
时光说笑 2021-02-05 07:57

If you search for skips lists implemented in Haskell, you won\'t find many. It is a probabilistic data structure needing a random number generator, meaning that any of these str

7条回答
  •  不要未来只要你来
    2021-02-05 08:50

    I once had a go at implementing a skip list in Haskell. Of course it was an immutable data structure (this is Haskell, after all). But that meant that the need for randomness disappeared; "fromList" just counted items and built skip arrays of the right length for each item (2 pointers every 4th item, 3 every 16th, 4 every 64th, etc).

    At that point I realised I was just building a more complicated version of a tree with a lot less ability to mutate it. So I gave up.

提交回复
热议问题