Assert

Adding a Single Fact at Run Time

 

There are three predicates to add a single fact at run time: assert, asserta and assertz.

These predicates will all take one or two arguments. The optional second argument is the name of a facts section (internal database). The assertion predicates always know which database to insert the fact in, because the names of the database predicates are unique within a program or module. However, you can use the optional second argument for type checking purposes in order to ensure that you are working on the correct database.

 

asserta(Fact)

 

asserta asserts a new fact into the database before the existing facts for the given predicate.

 

assertz(Fact)

 

assertz asserts a new fact after the existing facts for that predicate.

 

assert(Fact)

 

assert behaves like assertz.

Copyright © 1997-2003 EDMGROUP (Australia)