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

Synopsis

+Expr1 < +Expr2

Evaluates Expr1 and Expr2 as arithmetic expressions. The goal succeeds if the result of evaluating Expr1 is strictly less than the result of evaluating Expr2.

+Expr1 =:= +Expr2

Succeeds if the results of evaluating Expr1 and Expr2 are equal.

+Expr1 =< +Expr2

Succeeds if the result of evaluating Expr1 is less than or equal to the result of evaluating Expr2.

+Expr1 =\= +Expr2

Succeeds if the results of evaluating Expr1 and Expr2 are not equal.

+Expr1 > +Expr2

Succeeds if the result of evaluating Expr1 is strictly greater than the result of evaluating Expr2.

+Expr1 >= +Expr2

Succeeds if the result of evaluating Expr1 is greater than or equal to the result of evaluating Expr2.

Arguments


Expr1 expr
Arithmetic expression
Expr2 expr
Arithmetic expression

Description

All of these predicates evaluate Expr1 and Expr2 as arithmetic expressions and compare the results.

The possible values for Expr are spelled out in detail in ref-ari-aex.

Exceptions


instantiation_error

type_error

representation_error

domain_error
Expr1 or Expr2 does not evaluate to a number.

Examples

     | ?- 23 + 2.2  <  23 - 2.2.
     
     yes
     | ?- X = 31, Y = 25, X + Y  <  X - Y
     
     no
     
     | ?- 1.0 + 1.0 =:= 2.
     
     yes
     
     | ?- "a" =:= 97.
     
     yes
     
     | ?- 42 =< 42.
     
     yes
     
     | ?- "b" =< "a".
     
     no
     
     | ?- 7 =\= 14/2.
     
     no
     
     | ?- 7 =\= 15/2.
     
     yes
     
     | ?- "g" > "g".
     
     no
     
     | ?- 4*2 > 15/2.
     
     yes
     
     | ?- 42 >= 42.
     
     yes
     
     | ?- "b" >= "a".
     
     yes
     

Comments

Note that the symbol =< is used here rather than <=, which is used in some other languages. One way to remember this is that the inequality symbols in Prolog are the ones that cannot be thought of as looking like arrows. The < or > always points at the =.

See Also

ref-ari