Sublime构建错误的SWI-Prolog插件

Tar*_*rek 2 prolog swi-prolog sublimetext3

我知道这是一个有点愚蠢的问题,但我现在真的很绝望,因为我无法找到建立它的方法.我总是得到这个错误

ERROR: call/2: Undefined procedure: main/1
ERROR:   However, there are definitions for:
ERROR:         main/0
Run Code Online (Sandbox Code Playgroud)

即使我试过了

father(ahmad,samer).
father(ahmad,lolo).
father(ahmad,koko).


grandfather(X,Y):-
    father(U,X),
    father(Y,U).

main :- father(ahmad, X), writef('%t\n', [X]).
Run Code Online (Sandbox Code Playgroud)

那么有人可以帮助我以正确的方式做到这一点吗?

She*_*vic 5

对我来说工作得很好.

只需键入main. 不要忘记.,否则它将无法运行.这就是我得到的

2 ?- main.
samer
true ;
lolo
true ;
koko
true.
Run Code Online (Sandbox Code Playgroud)

如果要显示所有三个名称,请在true键入后;而不是按下Enter按钮.如果按Enter,则仅显示名字.

从你的代码我发现那ahmad是父亲,所以关于grandfather查询,我想我必须这样:

granfather(X,Y):- father(X,U),father(U,Y).
Run Code Online (Sandbox Code Playgroud)

因为在您的father查询中,father它位于左侧