如何在代码中执行查询?
例如:
person(abe,instructor).
person(bob,student).
person(cindy,student).
person(david,student).
person(abe,student).
% Like this, but this does not work
% :- person(X,Y).
加载程序后,我可以运行以下查询:person(X,Y)。
如何将此查询作为程序本身的一部分运行,以便程序加载后,它将运行查询并输出:
X = abe,
Y = instructor ;
X = bob,
Y = student ;
X = cindy,
Y = student ;
X = david,
Y = student ;
X = abe,
Y = student.