![]() ![]() ![]() |
![]() |
:=
Entity: predicate
<>=
Entity: predicate
Usage:
X is Y
X := Y
X <>= Y
is , := (two point equal) and <>= (diamond equal) do one and the same thing. They calculate the expression Y and bound it with variable X . The differences are only two. First is that := is stable on backtracking but is and <>= are not, i.e. after backtracking X will return its old value. Second is that is checks if the value of the expression is the same as the value of X and if they are different it fails but := and <>= don't care about the old value of X and change it anyway. If X is not instantiated then is is equivalent to <>= .
Example for :=
?- s(X), X=a, s(X), X:=b, s(X), fail.
s(X).
s(X) :- write(X), nl, fail.
Example for <>=
?- s(X), X=a, s(X), X<>=b, s(X), fail.
s(X).
s(X) :- write(X), nl, fail.