Retrieval by clause reference -- is it faster than retrieval by fact index

Hi,

I noticed that clause/3 enables retrieving a clause via reference.

clause (:Head, ?Body, ?Reference)

If i know a reference to an asserted fact; would a retrival with clause be a faster, more direct, lookup?

thank you,

Dan

Depends on the data. Of course you do not have to find the clause, so that is faster. Binding head and body is done through decompilation though and that is probably slower than executing the code (never really measured). If you want fast navigation through Prolog terms stored on the heap you should probably look at recorda/3 and recorded/3, using the references as pointers.

Hi Jan,

Yes, that is my intent – thank you for the pointer to recorda, (no pun intended :-))

Essentially, I am now thinking to have for each element (node and link) in a graph an asserted fact (record). while also keeping around an assoc with Link Elements as key, and a pair or list with from and to references in the value part.

Dan