Lexical comparison allows comparing terms without an attempt to
instantiate the terms. These predicates are therefore
meta-logical. The predicates (==)/2 and (\==)/2 perform an
equality test. The predicates (@<)/2, (@=<)/2, (@>)/2 and
(@>=)/2 use a linear ordering based on a lexical comparison.
The lexical comparison first looks on the basic type of the
involved terms. The ordering of the basic types is as follows:
Variables are ordered according to their internal instantiation
numbering. Integers, floats and decimals are arithmetically
ordered. But there is no mixing of integers, floats and decimals.
Atoms are ordered according to their internal character
representation. For compounds first the arity is compared, then
the functor is compared and finally the arguments from left to
right. The predicate compare/3 returns <, = or >.
?- 1 @< 2.0.
?- compare(O, 1, 2.0).
O = >
Reference types can always be used in equality tests. Whether a reference type can be compared depends on whether it implements the Java Comparable interface. The predicates locale_compare/[3,4] allow a locale comparison. In locale comparison the atoms and functors are ordered according to a locale specific Java collator. Locale comparison for reference types is not yet supported.
The following built-in predicates are provided: