Prolog Language Operators Term ordering


Example

Two terms may be compared via the standard ordering:

variables @< numbers @< atoms @< strings @< structures @< lists

Notes:

  • Structures compare alphabetically by functor first, then by arity and lastly by the comparison of each argument.

  • Lists compare by length first, then by each element.

Order operatorSucceeds if
X @< YX is less than Y in the standard order
X @> YX is greater than Y in the standard order
X @=< YX is less than or equal to Y in the standard order
X @>= YX is greater than or equal to Y in the standard order

Example queries:

?- alpha @< beta.
true.

?- alpha(1) @< beta.
false.

?- alpha(X) @< alpha(1).
true.

?- alpha(X) @=< alpha(Y).
true.

?- alpha(X) @> alpha(Y).
false.

?- compound(z) @< compound(inner(a)).
true.