This page exists to collect some little bits of Prolog code I have lying around from various projects. They're designed to work with SWI-Prolog, but in most cases should be reasonably easy to adapt to other environments.
Unless otherwise specified, these are all under the GNU GPL, version 2.
This collects points in a general metric space (such as N-dimensional vectors) and supports range queries - that is, you can put in a query point and extract all the points in the structure that are within a specified radius of the query point. The data structure is reasonably efficient for the case it was designed for, which is when you have a lot of queries and relatively few inserts. Inserts are not heavily optimized (sometimes large sections of the tree may be re-processed to ensure balance, and the reprocessing includes a quicksort-like median search which could be subject to pathological behaviour) but queries should be about as fast as the limits of the problem allow. In high dimensions, with genuinely high-dimensional data, even the best possible data structures may take a long time to answer queries. At some point I plan to enhance it to also support nearest-neighbour queries. There is undocumented code included in the file but not exported, for testing and performance optimization.
The code, version 0.1 (19 March 2006).
Just a few lines of code which I've found myself using over and over in Prolog projects.
The code, version 0.2 (16 April 2006).
No comments yet.