
Hi Toby,
On 4/24/07, Toby Hutton
Hi,
I'm trying to implement a fast kd-tree in Haskell. http://en.wikipedia.org/wiki/Kd-tree It's a binary tree representing space partitions.
Trees are pretty easy to implement in haskell, due to their inherent recursive nature. For example, you can do something like this: data Tree a = Node a [Tree a] Then the elements of the list are just the children subtrees of the current node. This is the approach taken by http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Tree.html for example. I personally think this is easier than trying to define an actual binary tree. With this approach, the algorithms mentioned in the wikipedia article above should be relatively straight-forward to implement. As for the paper cited, and the 'analogous' algorithm, you lost me. I don't see what the algorithm you gives has to do with the problem, so I'm quite confused. My suggestion would be to try to translate one of the algorithms from wikipedia, and use that. If you can't work out how to do this, feel free to check back with me and/or the list. Good luck! [snip] Andrew