[ Arithmetic | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
max(+Number1, +Number2, ?Maximum)
Unifies the maximum of Number1 and Number2 with Maximum.
- +Number1
- A number.
- +Number2
- A number.
- ?Maximum
- A variable or number.
Description
This predicate is used by the ECLiPSe compiler to expand evaluable
arithmetic expressions. So the call to max(Number1, Number2, Maximum)
is equivalent to
Maximum is max(Number1, Number2)
which should be preferred for portability.
In coroutining mode, if Number1 or Number2 are free variables, the call
to max/3 is delayed until these variables are instantiated.
Fail Conditions
Fails if the result of the evaluation does not unify with Maximum.
Resatisfiable
No
Exceptions
- (4) instantiation fault
- Number1 or Number2 is not instantiated (non-coroutining mode only).
- (5) type error
- Result is of a different type than the evaluation result.
- (24) number expected
- Number1 or Number2 is not of a numeric type.
- (24) number expected
- Result is neither a number nor a variable.
Examples
Success:
max(5, 2, 5).
max(2_3, 3_4, 3_4).
max(5.0 , 2.0, 5.0).
max(5, 2.0, 5.0). (The types are adjusted)
max(5, 2_0, 5_0). (The types are adjusted)
Fail:
max(1, 2, 3).
Error:
max(A, 2, 6). (Error 4).
max(1, 2, 2.0). (Error 5).
max(5, 2.0, 5). (Error 5).
max(4 - 2, 3, 3). (Error 24).
max(5, 2, r). (Error 24).
See Also
is / 2