Next: Arithmetic Functions
Up: Built-In Predicates
Previous: Operators
Arithmetic can be divided into some special purpose integer predicates
and a series of general predicates for floating point and integer
arithmetic as appropriate. The integer predicates are as ``logical'' as
possible. Their usage is recommended whenever applicable, resulting in
faster and more ``logical'' programs.
The general arithmic predicates are optionaly compiled now (see
please/3 and the -O
command line option). Compiled arithmetic
reduces global stack requirements and improves performance.
Unfortunately compiled arithmetic cannot be traced, which is why it is
optional.
The general arithmetic predicates all handle expressions. An
expression is either a simple number or a function. The arguments
of a function are expressions. The functions are described in
section
.
- between( +Low, +High, ?Value)
Low and High are integers,
. If
Value is an integer,
.
When Value is a variable it is successively bound to all
integers between Low and High.
- succ( ?Int1, ?Int2)
Succeeds if
. At least one of the arguments
must be instantiated to an integer.
- plus( ?Int1, ?Int2, ?Int3)
Succeeds if
. At least two of the
three arguments must be instantiated to integers.
-
- +Expr1
>
+Expr2
Succeeds when expression Expr1 evaluates to a larger number than Expr2.
-
- +Expr1
<
+Expr2
Succeeds when expression Expr1 evaluates to a smaller number than Expr2.
-
- +Expr1
=<
+Expr2
Succeeds when expression Expr1 evaluates to a smaller or equal number
to Expr2.
-
- +Expr1
>=
+Expr2
Succeeds when expression Expr1 evaluates to a larger or equal number
to Expr2.
-
- +Expr1
=\=
+Expr2
Succeeds when expression Expr1 evaluates to a number non-equal to
Expr2.
-
- +Expr1
=:=
+Expr2
Succeeds when expression Expr1 evaluates to a number equal to
Expr2.
- -Number is +Expr
Succeeds when Number has successfully been unified with the number
Expr evaluates to.
Next: Arithmetic Functions
Up: Built-In Predicates
Previous: Operators
Passani Luca
Tue Nov 14 08:58:33 MET 1995