What is the difference between this:
X \\= Y
and this piece of code:
dif(X, Y)
I thought that they should
dif/2
and (\=)/2
are the same as long as their arguments are ground. But only dif/2
is a pure relation that works correctly also with variables and can be used in all directions. Your example clearly shows that you should use dif/2
in this case, because you use your predicate not only to test, but also to generate solutions. The most widely used Prolog systems all provide dif/2
.