HELP DATABASE Aaron Sloman, April 1982
DATABASE is a global variable used by the following procedures and looping
constructs. (All except ALLREMOVE and ALLADD have HELP files with the same
name. The functions of ALLREMOVE and ALLADD can be inferred from ADD and
REMOVE.)
add(<item>); puts pattern into database
remove(<pattern>); removes item matching pattern from database
flush(<pattern>); removes ALL matching items from database
present(<pattern>); searches database for an item matching pattern
lookup(<pattern>); like present, but error if item not found
foreach iterates over database.
forevery iterates over combinations of database items
alladd(<list_of_items>); adds all the patterns to database
allremove(<list_of_patterns>);
removes all the patterns
allpresent(<list_of_patterns>);
checks that a combination of patterns can be
consistently instantiated in the database
which(<variables>,<list_of_patterns>) -> <list_of_values>;
finds items satisfying a test
PRESENT and ALLPRESENT return the result TRUE or FALSE
ADD, REMOVE, FLUSH, PRESENT, LOOKUP and FOREACH all set the value of the
variable IT to be the last database item matched.
ALLADD, ALLREMOVE, ALLPRESENT and FOREVERY all set the value of the variable
THEM to be the collection of database items matching the argument list.
All the procedures except ADD and ALLADD use MATCHES to match their arguments
against database items. Consequently, any pattern variables will be set by the
match.
REMOVE and LOOKUP both produce an error if they find no matching item.
To save the current version of DATABASE in the file, do
storedata(<filename>);
It can then be restored using *COMPILE or *LOAD.
Note:
This is primarily a teaching tool, so the database is stored as a simple
list of lists without any fancy indexing mechanism. For many purposes
where rapid access to a large database is required use *NEWPROPERTY.
See also
TEACH *DATABASE - for a tutorial introduction to the use of the database
HELP *SUPER - on LIB SUPER, an enhanced version of the DATABASEAuthor: Aaron Sloman, April 1982