1

I am learning about Prolog in class and was shown a way to automatically press the semicolon key until there are no more solutions. I have tried searching on Google but I get examples using findall which is not what was shown. Are there any other ways to automatically press ; in the Prolog shell?

For example, showing all the solutions without pressing ; repeatedly.

X = one ;
X = two ;
X = three ;
X = four.
4

1 回答 1

1

一个简单的解决方案,使用member/2for 举例说明,是fail/0在目标之后使用谓词:

?- member(X, [1,2,3]), writeq(X), nl, fail.
1
2
3
false.
于 2016-03-08T01:53:36.867 回答