假设我有以下规则:
unify('test', 'this is a test').
run :- write('Enter something: '),
read(X),
unify(X, Y),
write('The answer is '), write(Y).
然后我按如下方式运行它:
?- ['unify.pl'].
% unify.pl compiled 0.00 sec, -48 bytes
true.
?- run.
Enter something: test.
The answer is this is a test
true.
?- run.
Enter something: 'test'.
The answer is this is a test
true.
为什么 SWI-Prolog 统一test
和'test'
到unify('test', 'this is a test').
?我在回答关于 SO 的 Prolog 问题时遇到了这个问题。虽然我能够回答这个人的问题,但我无法解释这种特殊行为,我想知道其他人是否可以。