SWI-Prolog -- compare/3

Did you know ... Search Documentation:
SWI-Prolog owl logo Predicate compare/3
Availability:built-in
[ISO]compare(?Order, @Term1, @Term2)
Determine or test the Order between two terms in the standard order of terms. Order is one of <, > or =, with the obvious meaning.
Tags are associated to your profile if you are logged in
Tags:
LogicalCaptain said (2020年12月12日T13:52:11):0 upvotes 0 0 downvotes
Picture of user LogicalCaptain.

See

https://eu.swi-prolog.org/pldoc/man?section=standardorder

for the "Standard Order of Terms".

Beware the types:

?- compare(D,null,"null").
D = (>).
?- compare(D,"null",null).
D = (<).
?- compare(D,null,null).
D = (=).
?- compare(D,"null","null").
D = (=).

You may want to use assertion/1 to check your code for surprises here.

This I consider crazy (sorting by the names of variables, because logically compare/3 shouldn't have any access to those variable names; variable names are a feature of the source code, not of the process active at runtime). What should be returned here? Equality of course. These are unbound variables!

?- compare(D,X,Y).
D = (<).
?- compare(D,Y,D).
D = (>).
?- compare(D,X,X).
D = (=).
login to add a new annotation post.

AltStyle によって変換されたページ (->オリジナル) /