adds a new clause as first clause of a predicate to the database.
asserta/1 adds Clause as first clause of the predicate
which has the same functor and arity as Clause to the database.
If no corresponding predicate exists a new predicate is created.
If Clause is an atom or compound term whose principal functor is
different from ':-' then Clause is the head and 'true' is the body
of the new clause.
If Clause is a compound term whose principal functor is
':-'/2 then the left side (1st argument) of ':-' is the head
and the right side (2nd argument) the body of the new clause.
Clause atom or compound term
| asserta(f(a)). | Succeeds and adds the clause 'f(a) :- true' to the database in front of other clauses of the predicate f/1. |
| asserta((f(X,Z) :- g(X,Y), h(Y,Z))). | Succeeds and adds the clause 'f(X,Z) :- g(X,Y), h(Y,Z)' to the database in front of other clauses of the predicate f/2. |
| asserta(X). | instantiation_error. |
This predicate is part of the ISO-Prolog Standard.
| scroll to top |
|