The built-in predicates described in this section allows the user to compare Prolog terms. Prolog terms are totally ordered according to the standard total ordering of terms which is as follows (from the smallest term to the greatest):
A list is treated as a compound term (whose principal functor is ’.’/2).
The portability of the order of variables is not guaranteed (in the ISO reference the oder of variables is system dependent).
Templates
Description
These predicates compare two terms according to the standard total ordering of terms (section 7.3.1).
Term1 == Term2 succeeds if Term1 and Term2 are equal.
Term1 \== Term2 succeeds if Term1 and Term2 are different.
Term1 @< Term2 succeeds if Term1 is less than Term2.
Term1 @=< Term2 succeeds if Term1 is less than or equal to Term2.
Term1 @> Term2 succeeds if Term1 is greater than Term2.
Term1 @>= Term2 succeeds if Term1 is greater than or equal to Term2.
==, \==, @<, @=<, @> and @>= are predefined infix operators (section 7.14.10).
Errors
None.
Portability
ISO predicates.
Templates
Description
compare(Result, Term1, Term2) compares Term1 and Term2 according to the standard (section 7.3.1) and unifies Result with:
Errors
Result is neither a variable nor an atom | type_error(atom, Result) | |
Portability
GNU Prolog predicate.