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.


我希望inHands.返回这样的内容:

Left hand:
  empty

Right hand:
  empty


但是,这是我所看到的:

 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.


我在这里做错了什么?

最佳答案

原来我必须使用单引号,如下所示:

write('My text').

关于prolog - Prolog脚本的意外输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2257764/

10-11 03:02
查看更多