Often, it is necessary to check whether or not a term has a particular value.
If we know that the term will be bound to a number, we can use the
evaluable predicates =:=/2 or
= \ = /2, as explained earlier.
For other values, it may often be cheaper, in the appropriate circumstances,
to use the predicates ?=/2 or
\ = /2.
For example, consider a predicate p/2 that calls q/1
with its second argument if its first argument unifies with a,
and r/1 otherwise.
A na&̈#305;ve definition might be
p(a, X) :- !, q(X). |