首页 > 解决方案 > Prolog \+ 和 \= 有什么区别

问题描述

\= 和 \+ 有什么区别?

因为

?- 15\=14.
?- \+ 15=14.<--- this gives an error while the above does not.

为什么?他们不一样吗?

编辑:这是错误:

Compiling the file:
D:\Program Files\Strawberry Prolog Beta\Games\WarCraft.pro
Warning 4: The string \+ is not an operator. (line 1, before the first clause)
Error 16: Instead of the integer 15 what is expected here is something like an infix operator or a full stop. (line 1, before the first clause)
1 error, 1 warning.

另外我正在使用草莓序言,我也在 SWI prolog 上尝试过,仍然相同。

标签: prologlogical-operators

解决方案


我认为您正在将查询放入 Prolog 源文件。那不是他们应该去的地方:

  • 谓词定义进入 Prolog 源文件
  • 查询被输入到交互式 Prolog 顶层

尝试在没有输入文件的情况下运行 SWI-Prolog 程序。您应该会看到一个窗口,其中包含一些有关 SWI-Prolog 版本的信息性消息,然后是一个提示符?-。那是顶层。尝试在那里输入您的查询。所有查询都应该去那里。

我不知道Strawberry Prolog,但我怀疑那里是一样的。


推荐阅读