This appendix gives a brief description of each built-in predicate mentioned in this book and some others. They are all 'standard' predicates, which should be available in every version of Prolog, but inevitably there may be some exceptions to this. It is also possible that in some implementations of Prolog the definitions may vary slightly from those given here. In cases of disagreement, the definitions given in the supplier's documentation should always be taken as definitive.
Name of Predicate!/0 [exclamation mark symbol, pronounced 'cut']
Syntax! Description
Always succeeds. Used to control backtracking (see Chapter 7).
Name of Predicateappend/3
Syntaxappend(First,Second,Whole ) Description
Join or split lists (see Chapter 9).
Name of Predicatearg/3 Syntaxarg(N,Term,Arg) Description
N must be a positive integer and Term must be a compound term. Arg is unified with the Nth argument of Term.
Name of Predicateasserta/1 Syntaxasserta(Clause) Description
Adds a clause to the definition of a predicate at the beginning of its sequence of existing clauses (if any).
Name of Predicateassertz/1 Syntaxassertz(Clause) Description
Adds a clause to the definition of a predicate at the end of its sequence of existing clauses (if any).
Name of Predicateatom/1 Syntaxatom(Term) Description
Succeeds if and only if the given Term is a Prolog atom.
Name of Predicateatomic/1 Syntax atomic(Term) Description
Succeeds if and only if Term is an atom, a number, or a variable bound to either.
Name of Predicatecall/1 Syntaxcall(Goal) Description
Calls the given Goal. Succeeds if Goal succeeds and fails if Goal fails.
Name of Predicateconsult/1 Syntaxconsult(Filename) Description
Loads the program contained in the named disk file.
Name of Predicatedynamic/1
Syntaxdynamic(predicate_specification) Description
Used to specify that a predicate is 'dynamic', i.e. may be modified (see Page 110).
Name of Predicatefail/0 Syntaxfail
Description
Always fails. Used to force a program to backtrack.
Name of Predicatefindall/3 Syntaxfindall(Term,Goal,List) Description
Returns a list of all the instances of Term that satisfy goal Goal.
Name of Predicatefunctor/3
Syntaxfunctor(Term,Functor,Arity) Description
Succeeds if Term has the specified Functor and Arity.
Name of Predicateget/1 Syntaxget(Char) Description
This reads the next 'printable' (i.e. non-white-space) character from the current input stream, and unifies Char with its integer character code.
Name of Predicateget0/1 Syntaxget0(Char) Description
This reads the next character from the current input stream, and unifies Char with its integer character code.
Name of Predicatehalt/0 Syntaxhalt
Description
Terminates the current Prolog session and exits to the operating system.
Name of Predicateinteger/1 Syntaxinteger(Term) Description
Succeeds if and only if Term is an integer.
Name of Predicatelength/2 Syntaxlength(List,Length) Description
Tests the length of a list (see Chapter 9).
Name of Predicatelisting/1 Syntaxlisting(Atom) Description
Lists all predicates with the given name, irrespective of their arity.
Name of Predicatemember/2 Syntaxmember(Term,List ) Description
Gets or checks a member of a list (see Chapter 9).
Name of Predicatename/2 Syntaxname(Atom,List) Description
Converts between an atom and a list of characters (see Chapter 10).
Name of Predicatenl/0 Syntaxnl
Description
Outputs a carriage return and line feed to the current output stream, to complete a line of output.
Name of Predicateop/3
Syntaxop(Precedence,Type,Name) Description
Used to set, reset or clear the definition of an operator, using the given Precedence, Type and Name.
Name of Predicateput/1 Syntaxput(Integer) Description
Outputs the character corresponding to Integer to the current output stream.
Name of Predicateread/1 Syntaxread(Var) Description
Reads a term from the current input stream and attempts to assign the value to Var, which should previously be unbound.
Name of Predicatereconsult/1 Syntaxreconsult(Filename) Description
Loads the program contained in the named disk file. Any clauses for the same predicates already in the database are first deleted.
Name of Predicaterepeat/0 Syntaxrepeat
Description
Always succeeds when called, both when called and on backtracking. Used to provide a looping facility.
Name of Predicateretract/1 Syntaxretract(Clause) Description
Deletes the first matching clause from a predicate (see Chapter 8).
Name of Predicateretractall/1 Syntaxretractall(Head) Description
Deletes all clauses whose heads match the given Head (see Chapter 8).
Name of Predicatereverse/2 Syntaxreverse(List,Reverse) Description
Reverses the order of elements in a list (see Chapter 9).
Name of Predicatesee/1 Syntaxsee(Stream) Description
Sets Stream to be the current input stream. Stream may be the name of a disk file or the atom user (referring to the console input device). If Stream refers to a disk file which is not open, it is automatically opened for reading. If the file is already open, input continues from the point immediately after the previously-read character.
Name of Predicateseeing/1 Syntaxseeing(Stream) Description
Stream is bound to the name of the current input stream, which may be a disk file or the atom user (referring to the console input device).
Name of Predicateseen/0 Syntaxseen
Description
Closes the file associated with the current input stream, and resets the current input stream to user.
Name of Predicatestatistics/0 Syntaxstatistics
Description
Displays statistics about the current session.
Name of Predicatetell/1 Syntaxtell(Stream) Description
Sets the current output stream, which may be a disk file or the atom user (referring to the console output device). If Stream refers to a disk file which is not yet open, it is automatically opened for writing. If the file was already open, output continues from the point immediately after the previously written character.
Name of Predicatetelling/1 Syntaxtelling(Stream) Description
Gets the current output Stream, which may be a disk file or the atom user (referring to the console output device). Stream is bound to the name of the current output stream.
Name of Predicatetold/0 Syntaxtold
Description
Closes the file associated with the current output stream, and resets the current output stream to user.
Name of Predicatetrue/0 Syntaxtrue
Description Always succeeds.
Name of Predicate write/1 Syntaxwrite(Term) Description
Writes Term to the current output stream, in unquoted syntax.
Name of Predicatewriteq/1 Syntaxwriteq(Term) Description
Writes Term to the current output stream, in quoted syntax.