These predicates test the ordering of two terms as defined by the specification.
A goal executing any of these built-in predicates simply succeeds or fails; there is no side effect, unification, or error.
@=</2
(term less than or equal), ==/2
(term identical), \==/2
(term not identical), @</2
(term less than), @>/2
(term greater than), @>=/2
(term greater than or equal)These predicates also test the identity and term-precedence of their arguments. As an example, '@=<'(X, Y)
is true iff X
preceds Y
as defined by the specification, or X
and Y
are identical terms.
Templates and modes for the predicate are as follows:
'@=<'(@term, @term) '=='(@term, @term) '\\=='(@term, @term) '@<'(@term, @term) '@>'(@term, @term) '@>='(@term, @term)
Let's start with some simple tests verifying success of failure of single goals.
jTrolog.engine.SimpleGoalFixture | ||
goal | success() | exception() |
'@=<'(1.0, 1). | true | no exception |
'@<'(1.0, 1). | true | no exception |
'\\=='(1, 1). | false | no exception |
'@=<'(aardvark, zebra). | true | no exception |
'@=<'(short, short). | true | no exception |
'@=<'(short, shorter). | true | no exception |
'@>='(short, shorter). | false | no exception |
'@<'(foo(a, b), north(a)). | false | no exception |
'@>'(foo(b), foo(a)). | true | no exception |
'@<'(foo(a, X), foo(b, Y)). | true | no exception |
'@<'(foo(X, a), foo(Y, b)). | no exception | |
'@=<'(X, X). | true | no exception |
'=='(X, X). | true | no exception |
'@=<'(X, Y). | no exception | |
'=='(X, Y). | false | no exception |
\==(_, _). | true | no exception |
'=='(_, _). | false | no exception |
'@=<'(_, _). | no exception | |
'@=<'(foo(X, a), foo(Y, b)). | no exception |
The results of the tests for Term comparison are as follows:
fit.Summary |