开发者

prolog syntax problem

开发者 https://www.devze.com 2022-12-14 10:08 出处:网络
I can\'t开发者_开发百科 distinguish these symbols: = and =:= \\= and =\\= [X,Y] and [X|Y] What’s the difference ?For the comparison operators (=, =:=, \\=, =\\=):

I can't开发者_开发百科 distinguish these symbols:

= and =:=

\= and =\=

[X,Y] and [X|Y]

What’s the difference ?


For the comparison operators (=, =:=, \=, =\=):

  • = succeeds if the terms unify (basically, if they're bound together)
  • =:= succeeds if the values of the terms are equal (should be equivalent to = if you're dealing with numbers, I believe)
  • \= is the negation of =
  • =\= is the negation of =:=

For more info about these operators and more, see this page.

For the list operators, [X|Y] is a way to refer to a list where X is the first element and Y is the list of the remaining elements. [X, Y] is just another way to refer to this, but it limits Y to being a single element, instead of possibly a whole list of them. For more info, see this section of the same page.

0

精彩评论

暂无评论...
验证码 换一张
取 消