Logic programming library development log

In order to make a reasonably efficient logic programming interpreter, I’ll need to implement memoization. I edited some code I used earlier for memoizing recursive operations:


(corrected version; the original contained a bug)

When I’m going to use this for storing solutions to a goal (“relation” will be item 1 of the arguments), I need to make sure that the number of arguments of that type of relation is always the same, for this algorithm to work.. So if a type of relation’s arguments number is variable, I may have to insert the arity as an extra argument for memoization.

The function uses the following simple lookup function:

I would have preferred to use item (key) of (table) - unfortunately that doesn’ t work for numbers, so I made this one up.