[ ECLiPSe Term Comparison built-in.|Group Index| Full Index]

compare_instances( ?Relationship, ?Term1, ?Term2)

Succeeds if Relationship is an atom describing the instance relationship between Term1 and Term2.

?Relationship Unifiable to one of the special atoms ('<', '>', '='), describing the relationship between Term1 and Term2.
?Term1 Prolog term.
?Term2 Prolog term.

Description

Succeeds if Relationship is unified with one of the three term relationship symbols indicated by '<', '>', '=' where:

'<': Term1 is an instance of Term2.

'>': Term2 is an instance of Term1.

'=': Term1 is variant of Term2.

For the definition of instance and variant refer to instance/2 and variant/2, respectively.

Fail Conditions

Fails if Relationship does not unify to the instance relationship between Term1 and Term2 or if none of the terms is an instance of the other.

Resatisfiable

No.

Exceptions

Examples


   Success:
   compare_instances(Rel,X,Y), Rel == '='.
   compare_instances(=, [a,X], [a,Y]).
   compare_instances(<, [a,b], [X,Y]).
   compare_instances(<, [X], [X|Y]).
   compare_instances(>, X, f(1,1)).
   compare_instances(<, f(1,1), X).
   Fail:
   compare_instances(Rel, f(X), 1).
   compare_instances(Rel, 1, f(X)).
   compare_instances(<, X, a).


See Also

instance / 2, variant / 2