Next: List Manipulation
Up: Built-in predicates
Previous: Arithmetic Functions
  Contents
  Index
Prolog predicates can be given the role of arithmetic function. The
last argument is used to return the result, the arguments before the
last are the inputs. Arithmetic functions are added using the
predicate arithmetic_function1, which takes the head as its argument.
Arithmetic functions are module sensitive, that is they are only
visible from the module in which the function is defined and declared.
Global arithmetic functions should be defined and registered from
module user. Global definitions can be overruled locally in
modules. The builtin functions described above can be redefined as
well.
- arithmetic_function1+Head
Register a Prolog predicate as an arithmetic function (see is2,
2, etc.). The Prolog predicate should have one more
argument than specified by Head, which it either a term Name/Arity, an atom or a complex term. This last argument is an unbound
variable at call time and should be instantiated to an integer or
floating point number. The other arguments are the parameters. This
predicate is module sensitive and will declare the arithmetic function
only for the context module, unless declared from module user.
Example:
current_arithmetic_function1?Head
Successively unifies all arithmetic functions that are visible from
the context module with Head.
Next: List Manipulation
Up: Built-in predicates
Previous: Arithmetic Functions
  Contents
  Index
Dr. Richard Botting
2001-12-12