=:=/2, =\=/2, >/2, >=/2, </2, =</2

compare the values of two expressions according to the given operation.

+Expression1 =:= +Expression2 +Expression1 =\= +Expression2 +Expression1 > +Expression2 +Expression1 >= +Expression2 +Expression1 < +Expression2 +Expression1 =< +Expression2

These predicates compare the values of Expression1 and Expression2. They succeed if the comparison of the result of the left basic arithmetic operation (Expression1) and of the result of the right basic arithmetic operation (Expression2) corresponding to the given operation is true, otherwise they fail.

Operator op Meaning
=:= Arithmetic Equal
=\= Arithmetic Not Equal
> Arithmetic Greater Than
>= Arithmetic Greater Than Or Equal
< Arithmetic Less Than
=< Arithmetic Less Than Or Equal

'=:=', '=\=', '<', '=<', '>', '>=' are predefined infix-operators. The predefined priority is 700 and they are non-associative (see also current_op/3).

Arguments

Expression1       +evaluable

Expression2       +evaluable

Examples

------- =:= -------

'=:='(2*4, 4*2). Succeeds.

X=6-3, X+6 =:= X*3. Succeeds with substitution X <- 3.

X=4, Y=4.0, X =:= Y. Succeeds with substitution X <- 4, Y <- 4.0.

'=:='(3,2). Fails.

1 =:= X/3. Exception.

S =:= 2/0. Exception.

------- =\= -------

100 =\= 101. Succeeds.

'=\\='(2*4, 4*2). Fails.

X=6-3, X+7 =\= X*3. Succeeds with substitution X <- 3.

X=4, Y=4.0, X =\= Y. Fails.

'=\\='(3,2). Succeeds.

1 =\= X/3. Exception.

S =\= 2/0. Exception.

------- < -------

X=3, Y=4, X < Y. Succeeds with substitution X <= 3, Y <- 4.

3.0 < 3.1. Succeeds.

X=11, 12 < X. Fails.

1 < X. Exception.

------- =< -------

X=7, Y=8, X =< Y. Succeeds with substitution X <- 7, Y <- 8.

X=5, Y=5.0, X =< Y. Succeeds with substitution X <- 5, Y <- 5.0.

8 =< 7. Fails.

------- > --------

X=14.0, Y=14.3, X+1 > Y. Succeeds with substitution X <- 14.0, Y <- 14.3.

5.7 > 5. Succeeds.

X=11, X > 12. Fails.

X > 3. Exception.

------- >= -------

X=4, Y=3, X >= Y. Succeeds with substitution X <- 4, Y <- 3.

X=6, Y=7.00, X+1 >= Y. Succeeds with substitution X <- 6, Y <- 7.0.

4.6 >= 4.5999. Fails.

Standard

These predicates are part of the ISO-Prolog Standard.


Up read on...