我是 SWI-Prolog 的初学者(但对 Borland Prolog 有一些经验),我遇到了以下测试代码的奇怪行为:
I'm beginner in SWI-Prolog (but have some experience in Borland Prolog), and I've faced with a strange behavior for the following test code:
test(10). test(1).期望查询 ?-test(A) 得到 2 个解,比如 A = 10;A = 1.但是,仅生成 A = 10.我不使用这里的切口.也许在 SWI-Prolog 中默认关闭回溯?
It is expected for query ?-test(A) to get 2 solutions, something like A = 10; A = 1. However, only A = 10 is produced. I don't use the cut here. Maybe backtracking is off by default in SWI-Prolog?
提前致谢
推荐答案抱歉,答案很简单(参见 SWI-Prolog 文档):
Sorry, the answer is very simple (see SWI-Prolog doc):
用户可以输入分号 (;) 或空格键,如果他想要其他解决方案.如果您不想看到更多答案,请使用返回键.如果用户使用返回键或 Prolog 知道没有更多答案,Prolog 会以句号 (.) 完成输出.如果 Prolog 找不到(更多)答案,它会写为 false.
The user can type the semi-colon (;) or spacebar, if (s)he wants another solution. Use the return key if you do not want to see the more answers. Prolog completes the output with a full stop (.) if the user uses the return key or Prolog knows there are no more answers. If Prolog cannot find (more) answers, it writes false.
更多推荐
在 SWI
发布评论