如何在 SWI-Prolog 中扩展结果列表? [英] How to expand a resulting list in SWI-Prolog?

查看:15
本文介绍了如何在 SWI-Prolog 中扩展结果列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

?- length(L,25).
L = [_G245, _G248, _G251, _G254, _G257, _G260, _G263, _G266, _G
269|...].

如果我在长度谓词之后使用 write(L),那么解释器会打印列表两次,一次展开,另一次不展开.

If I use write(L) following the length predicate then the interpreter prints the list twice, one expanded and the other not.

推荐答案

为了防止输出过长,有深度限制.您可以使用 set_prolog_flag/1 更改它.

There is a limit on the depth to prevent too long output. You can change it with set_prolog_flag/1.

?- length(L, 25).
L = [_G257, _G260, _G263, _G266, _G269, _G272, _G275, _G278, _G281|...].

?- current_prolog_flag(toplevel_print_options, V).
V = [quoted(true), portray(true), max_depth(10), priority(699)].

?- set_prolog_flag(toplevel_print_options, [quoted(true), portray(true), max_depth(100), priority(699)]).
true.

?- length(L, 25).
L = [_G257, _G260, _G263, _G266, _G269, _G272, _G275, _G278, _G281, _G284, _G287, _G290, _G293, _G296, _G299, _G302, _G305, _G308, _G311, _G314, _G317, _G320, _G323, _G326, _G329].

您还可以通过从选项列表中删除限制来完全删除限制.

You can also remove the limit completely by removing it from the options list.

这篇关于如何在 SWI-Prolog 中扩展结果列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆