SWI-Prolog - 显示长列表
我正在使用 SWI-Prolog,我正在尝试打印一个列表,但如果该列表有超过 9 个项目 - 它看起来像那样 -
[1, 15, 8, 22, 5, 19, 12, 25, 3|...]
有没有办法显示整个列表?
I'm using SWI-Prolog and I'm trying to print a list but if the list has more than 9 items - it look like that -
[1, 15, 8, 22, 5, 19, 12, 25, 3|...]
is there a way to show the whole list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看一下:http://www.swi-prolog.org/FAQ/AllOutput。 html
简单的解决方案是在给出答案后键入 w,即:
按下“w”键后,末尾会显示“[write]”,并且完整的解决方案出现在下一行。
Have a look at: http://www.swi-prolog.org/FAQ/AllOutput.html
The simple solution is to type w after the answer is given, i.e.:
After you have pressed the "w"-key "[write]" is displayed at the end and the full solution appears in the next line.
我找到了两种方法。
1.
然后执行打印截断列表的命令。
(set_prolog_flag 文档)
2.
(AllOutput 文档)
Put
; true.
在调用结束时会生成一个长列表。然后按键盘上的 w 键。结果是:I've found two ways.
1.
Then do your command that is printing a truncated list.
(set_prolog_flag documentation)
2.
(AllOutput documentation)
Put
; true.
at the end of the call that results in a long list. Then push the w key on your keyboard. The result is:如果 prolog 仅返回一个答案,您可以通过键入“; true”使其等待。在谓语之后。然后,如果您按“w”,您将看到文档中编写的整个列表: http://www.swi-prolog.org/FAQ/AllOutput.html
If prolog returns only one answer, you can make it wait by typing "; true." after the predicate. Then, if you press "w", you will get to see the whole list as written in the doc : http://www.swi-prolog.org/FAQ/AllOutput.html
会做得足够整洁。这就是我所做的。
变体:
print_term
的[]
参数是一个(空)选项列表。有关详细信息,请参阅文档。will do it neatly enough. That's what I do.
Variation:
The
[]
argument toprint_term
is an (empty) list of options. For more information, see documentation.如果您希望 SWI-Prolog 默认显示整个列表,您可以将此行添加到您的 init 文件:
您可以从 GUI 轻松修改 init 文件(设置 => 用户 init 文件)。
If you want that SWI-Prolog will show the whole list by default you can add this line to your init file:
You can modify the init file easily from the GUI (Settings => User init file).