So I can’t claim to understand the SWI-Prolog indexing system, but it would be useful to have some kind of heuristic for writing code that’s quick to index.
I have a large for manually written static data set. So I like to write it in a frame-like syntax:
frame(id, [slot-"value"]). % with may a dozen slots max
I’m going to want to query this data with typically either the
slot ground, so I’ll write a program to convert the syntax. The question is, what syntax?
triple(id, slot, "value").
query(ID, Slot, Value) :- atom(ID), !, call(ID, Slot, Value). query(ID, Slot, Value) :- atom(Slot), !, call(Slot, ID, Value). id(slot, "value"). slot(id, "value").
If I query with only the slot ground would the triple lookup be comparable to if the subject were ground? Or would the second option with
slot/2 pairs be the faster option exploiting first-argument and