prolog - 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 上尝试过,仍然相同。
解决方案
我认为您正在将查询放入 Prolog 源文件。那不是他们应该去的地方:
- 谓词定义进入 Prolog 源文件
- 查询被输入到交互式 Prolog 顶层
尝试在没有输入文件的情况下运行 SWI-Prolog 程序。您应该会看到一个窗口,其中包含一些有关 SWI-Prolog 版本的信息性消息,然后是一个提示符?-
。那是顶层。尝试在那里输入您的查询。所有查询都应该去那里。
我不知道Strawberry Prolog,但我怀疑那里是一样的。
推荐阅读
- algorithm - 如果条件复杂度 O(n * log(n))
- sql - 当给定日期和客户存在多个时间戳时,是否可以将每日客户频率过滤器减少到少于 2 个子查询?
- postgresql - Postgres - 扩展文件夹中的附加文件
- php - 如何使用自定义帖子类型+和结帐页面制作 woocommerce 商店页面
- c# - Unity根据参数'Type'设置Gameobject
- javascript - 条件异步瀑布
- javascript - 使用 Javascript 在子标签页之间导航的快速方法
- python - 我如何让基于 Web 的应用程序与带有套接字的 python 服务器通信
- c++ - c ++分离转向算法显示奇怪的结果
- antlr - 当存在歧义时,Antlr 4 获取(打印)所有解析树