Prolog gives error “undefined procedure” when tryi

2019-04-04 07:39发布

I'm using SWI-Prolog on Windows and am getting the following error:

14 ?- parent(X, Y) :- child(Y, X).
ERROR: toplevel: Undefined procedure: (:-)/2 (DWIM could not correct)

I'm not entirely sure what's going on, as this worked last week and I am just starting to learn Prolog.

2条回答
smile是对你的礼貌
2楼-- · 2019-04-04 08:17

The FAQ says it all: http://www.swi-prolog.org/FAQ/ToplevelMode.html

You need to create a file and write your program with rules there. The top level command line will only allow you to issue queries.

查看更多
The star\"
3楼-- · 2019-04-04 08:31

You can try it this way

1 ?- assert(a(A,B):-A=B).
true.

2 ?- a(B,c).
B = c.
查看更多
登录 后发表回答