I want to find the existence of a term in my current prolog program as quickly as possible, without a prolog engine intersecting all terms until it reaches an existing term.
I did not find any evidence of this. But I assume that this
animal(lion). animal(zebra). ... % thousands of other animals ... animal(tiger).
The swi-prolog engine will have to go through thousands of animals trying to team up with a tiger to confirm that the animal (tiger) is in my prologue database.
In other languages, I believe that HashSet will solve this problem by allowing you to search for O (1) ... However, I cannot find hash tables or hash tables in the swi-proog documentation.
Is there a swi-prolog library for the hash, or can I somehow create it myself using term_hash \ 2?
Information about the bonus, I most likely will have to look at some dynamically added data, either added to the hashset data structure, or using assertz
source share