我正在使用SWI-Prolog,并试图打印一个列表,但如果该列表包含9个以上的项目-它看起来是这样的-
[1, 15, 8, 22, 5, 19, 12, 25, 3|...] 有没有办法显示整个列表?
发布于 2014-01-04 22:14:32
看看:http://www.swi-prolog.org/FAQ/AllOutput.html
简单的解决方案是在给出答案后键入w,即:
?- n_queens_problem(10,X).
X = [1, 3, 6, 8, 10, 5, 9, 2, 4|...] [write]
X = [1, 3, 6, 8, 10, 5, 9, 2, 4, 7] 按下后,"w"-key "write“将显示在末尾,完整解决方案将显示在下一行中。
发布于 2016-02-17 10:06:00
如果prolog只返回一个答案,您可以通过键入";true“让它等待。在谓词之后。然后,如果您按下"w",您将看到文档中所写的整个列表:http://www.swi-prolog.org/FAQ/AllOutput.html
发布于 2016-02-18 04:43:35
?- createListSomehow(List), print(List), nl.会做得足够整洁。这就是我要做的。
变体:
?- use_module(library(pprint)). %load a library to do pretty-printing
?- createListSomehow(List), print_term(List,[]), nl.print_term的[]参数是一个(空)选项列表。有关更多信息,请访问see documentation。
https://stackoverflow.com/questions/8231762
复制相似问题