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 operator | Succeeds if |
---|---|
X @< Y | X is less than Y in the standard order |
X @> Y | X is greater than Y in the standard order |
X @=< Y | X is less than or equal to Y in the standard order |
X @>= Y | X 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.