Next: mpg-ref-compile, Previous: mpg-ref-close, Up: mpg-bpr [Contents][Index]
compare/3
ISOcompare(-Order, +Term1, +Term2)
succeeds if the result of comparing terms Term1 and Term2 is Order
order
=
if Term1 is identical to Term2,
<
if Term1 is before Term2 in the standard order,
>
if Term1 is after Term2 in the standard order.
term
term
The standard order is described in ref-lte-cte. Note that the standard order is not, in general, well defined for cyclic terms.
The goal (A) is equivalent to (B):
| ?- compare(=, Term1, Term2). (A)
|?- (Term1 == Term2). (B)
The following query succeeds, binding R to <
, because 1 comes
before 2 in the standard order.
| ?- compare(R, 1, 2). R = <
If Order is supplied, and is not one of <
, >
, or
=
,
then an error is thrown, as follows.
type_error(atom, Order)
if Order is neither a variable nor an atom.
domain_error(order, Order)
if Order is an atom but not <
, =
, or >
.
These errors were added in SICStus Prolog 4.3 for alignment with the ISO Prolog standard. Previous versions of SICStus Prolog simply failed instead of reporting an error.
@</2
,
@=</2
,
@>/2
,
@>=/2
,
SP_compare()
,
ref-lte-cte.