next up previous contents
Next: (Compound) Terms as Up: Prolog Syntax Previous: Variables

Compound Terms

A Compound Term is a functor with a (fixed) number of arguments each of which may be a Prolog term.

This means that we can arbitrarily nest compound terms. For some examples:

 
happy(fred)

principal functor = happy

1st argument = a constant (atom)

sum(5,X)

principal functor = sum

1st argument = constant (integer)

2nd argument = variable

not(happy(woman))

principal functor = not

1st argument = compound term

Nesting compound terms may be of use to the programmer. For example, the clause

 
fact(fred,10000).

is not as informative as
 
fact(name(fred),salary(10000)).

which can be thought of as defining a PASCAL-type record structure.



Paul Brna
Mon May 24 20:14:48 BST 1999