【发布时间】:2015-01-26 10:35:41
【问题描述】:
我使用的是 SWI-PROLOG 6.6.6 版
我想打印特定谓词类型的所有属性。
我有一个名为 law 的谓词,其元数为 2。
一些事实是
law(borrow,'To borrow Money on the credit of the United States').
law(commerce,'To regulate Commerce with foreign Nations, and among the several States, and with the Indian Tribes').
law(unifomity,'To establish an uniform Rule of Naturalization, and uniform Laws on the subject of Bankruptcies throughout the United States').
law(money,'To coin Money, regulate the Value thereof, and of foreign Coin, and fix the Standard of Weights and Measures').
law(punishment,'To provide for the Punishment of counterfeiting the Securities and current Coin of the United States').
law(establishment,'To establish Post Offices and post Roads').
law(exclusiverights,'To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries').
law(court,'To constitute Tribunals inferior to the supreme Court').
等等
现在我想通过输入法律的类型来访问它。 比如,
power(X) :- law(X,Y), display('\nCongress has the power : '),display(Y).
powers(ALL) :- display('\nCongress has the powers : '), law(_,Y), display('\n'), display(Y).
这非常有效。现在,我也想让用户知道所有类型的法律都有哪些,以便用户可以输入它作为查询来获取相应的法律。
前power(money).
为此,我进行了查询以获取所有这些关键字并将它们添加到列表中并显示该列表。 但是最终打印出来的列表并不完整。
powerList(L) :- findall(X,law(X,_), L).
我使用此代码获取列表。 但是控制台上的输出是
L = [borrow, commerce, unifomity, money, punishment, establishment, exclusiverights, court, piracyfelony|...].
但是,即使在盗版重罪之后,还有更多的法律类型,并且它们不会打印到控制台上。如何打印它们?
【问题讨论】:
-
SWI-Prolog 网站的常见问题解答为您提供答案:swi-prolog.org/FAQ/AllOutput.html
-
@PauloMoura:已过时 7
-
@false 问题以“我使用的是 SWI-PROLOG 6.6.6 版”开头。
标签: list prolog prolog-toplevel