Prolog脚本的意外输出
我希望Prolog脚本的意外输出,prolog,Prolog,我希望inHands.返回如下内容: leftHand(empty). rightHand(empty). inHands :- write("Left hand:"), nl, leftHand(X), tab(2), write(X), nl, nl, write("Right hand:"), rightHand(Y), tab(2), write(Y), nl. 24 ?- inHand
inHands.
返回如下内容:
leftHand(empty).
rightHand(empty).
inHands :-
write("Left hand:"),
nl,
leftHand(X),
tab(2),
write(X),
nl,
nl,
write("Right hand:"),
rightHand(Y),
tab(2),
write(Y),
nl.
24 ?- inHands.
[76, 101, 102, 116, 32, 104, 97, 110, 100, 58]
empty
[82, 105, 103, 104, 116, 32, 104, 97, 110, 100, 58] empty
true.
然而,我看到的是:
Left hand:
empty
Right hand:
empty
我做错了什么?结果我不得不用这样的单引号:
leftHand(empty).
rightHand(empty).
inHands :-
write("Left hand:"),
nl,
leftHand(X),
tab(2),
write(X),
nl,
nl,
write("Right hand:"),
rightHand(Y),
tab(2),
write(Y),
nl.
24 ?- inHands.
[76, 101, 102, 116, 32, 104, 97, 110, 100, 58]
empty
[82, 105, 103, 104, 116, 32, 104, 97, 110, 100, 58] empty
true.