IF Computer > MINERVA > Manual > Reference > Predicates > Arithmetic comparison > =:=/2, =\=/2, >/2, >=/2, </2, =</2

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

MINERVA
ifcomputer logo
f
Expert Services on the Web

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.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/arithm_comp/arithm_comp/print_en.html
published 2008/5/12 update 1998/8/5 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS