7.3.1 Comparison of Terms

Two terms are compared according to the standard ordering, which is defined below. Items listed at the beginning come before the items listed at the end. For example, numbers are less than atoms in the standard ordering.

  1. Variables, in age ordering (older variables come before younger variables).
  2. Numbers, in numerical ordering.
  3. Atoms, in character code (ASCII) ordering.
  4. String, in standard string odering.
  5. Compound terms are compared in the following order:
    1. Arity, in numerical ordering.
    2. Functor, in standard ordering.
    3. Arguments, in standard ordering, from left to right.
  6. Sets, in dictionary order on elements.
  7. Lists, in dictionary order on elements.

The above ordering is used when constructing sets.

The following relations use the above ordering to test terms.

Term1 @> Term2

Succeeds if Term1 is greater thanTerm1 in the above ordering.

Term1 @>= Term2

Succeeds if Term1 is greater than or equal to Term2 in the above ordering.

Term1 @< Term2

Succeeds if Term1 is less thanTerm1 in the above ordering.

Term1 @=< Term2

Succeeds if Term1 is less than or equal to Term2 in the above ordering.

On This Site