在终端中键入“prolog”会得到:
GNU Prolog 1.3.0
By Daniel Diaz
Copyright (C) 1999-2007 Daniel Diaz
| ?-
打字:
| ?- member(2, [1,2,3]).
获取:
true ?
然后按回车得到:
yes
打字:
| ?- member(4, [1,2,3]).
得到:
no
当我写一个文件时;test.pl 由以下内容组成:
:- member(4, [1,2,3]), nl, halt.
然后在终端中写入:
| ?- [test2].
我得到:
compiling /path/test.pl for byte code...
/path/test.pl:1: warning: unknown directive (',')/2 - maybe use initialization/1 - directive ignored
/path/test.pl compiled, 1 lines read - 139 bytes written, 11 ms
yes
这里的答案应该是否定的?我究竟做错了什么。另外,您将如何在 prolog 中执行此操作:
if (testInPrologTerminal(member(4, [1,2,3])) { do this; }
即,我想向 prolog 顶层发送查询,并得到答案