Difference between X\=Y and dif(X,Y)

前端 未结 1 1599
南笙
南笙 2021-01-19 14:54

What is the difference between this:

X \\= Y

and this piece of code:

dif(X, Y)

I thought that they should

相关标签:
1条回答
  • 2021-01-19 15:13

    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.

    0 讨论(0)
提交回复
热议问题