Summary
The type of a term can be tested by the following predicates:
- var(X) X is a (non-instantiated) variable
- nonvar(X) X is not a variable
- atom(X) X is an atom
- integer(X) X is an integer
- atomic(X) X is either an atom or an integer
Terms can be constructed or decomposed:
Term = .. [Functor | ArgumentList]
functor( Term, Functor, Arity)
arg(N, Term, Argument)
name(Atom, CharacterCodes)
A prolog program can be viewed as a relational database that can be updated by the following procedures:
assert(Clause) add Clause to the program
asserta(Clause) add at the beginning
assertz(Clause) add at the end
retract(Clause) remove a clause that matches Clause
All the objects that satisfy a given condition can be collected into a list by the predicates:
bagof(X, P, L) L is the list of all X that satisfy condition P
setof(X, P, L) L is the sorted list of all X that satisfy condition P
findall(X, P, L) similar to bagof
repeat is a control facility that generates an unlimited number of alternatives for backtracking