Hi Lindsay, I like a lot what you are doing with fixed point scaling and lookup tables. It reminds me of programming in the Forth language, years ago.
The formal name of the algorithm coded in the fastNth primitive is Digital Tree Searching, a special case of Radix Searching. The algorithm is the same as that for Binary Tree Searching, except that we branch in the tree not according to the result of the comparison between keys (as idx does), but according to the key's bits. Because of the unavoidable lisp virtual machine overhead, a C primitive that searches this Digital Tree is almost as fast as a C primitive that just uses an static array in C. This is not the case with idx, as the comparison of keys that it makes at each level is expensive. But idx can be used for many more things, a digital tree seems to be a specialized tool. No need to use shared libs, as the fastNth primitive is general enough to handle any big array. Enrique.
