我在此Prolog Code行10单词上有一个错误,首先我无法弄清楚我的错误
go:-
university(area),
write('Shall we start?: '),
write(area),
nl,
undo.
university(csandse) :- csandse, !.
csandse :-
verify(labs),
verify(classrooms),
verify(Teachers Staffroom),
verify(Department's faculty office).
ask(Question):-
write('which area of department you want to visit?: '),
write(Question),
write('? '),
read(Response),
nl,
( (Response == yes; Response == y)
assert(yes(Question));
assert(no(Question)), fail).
:- dynamic yes/1, no/1.
verify(S) :-
(yes(S)
true ;
(no(S)
fail ;
ask(S))).
go:-
university(area),
write('Shall we start?: '),
write(area),
nl,
undo.
university(csandse) :- csandse, !.
csandse :-
verify(labs),
verify(classrooms),
verify(Teachers Staffroom),
verify(Department's faculty office).
ask(Question):-
write('which area of department you want to visit?: '),
write(Question),
write('? '),
read(Response),
nl,
( (Response == yes; Response == y)
assert(yes(Question));
assert(no(Question)), fail).
:- dynamic yes/1, no/1.
verify(S) :-
(yes(S)
true ;
(no(S)
fail ;
ask(S))).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经编辑了该问题以添加代码格式;我们可以看到部门教师办公室中途的颜色变化:
swish 中。正如@brebs的评论,从资本开头的东西是变量,必须用单个引号包裹才能是原子。被用作撇号的引号的人需要使撇号逃脱出来:
I've edited the question to add code formatting; we can see the colour changes midway through Department's faculty office:
because the apostrophe is throwing it off. The same colour change happens in SWISH. As @brebs comments, things starting with a capital are Variables and must be wrapped in single quotes to be atoms. Ones with quotes used as apostrophes need to have the apostrophe escaped with a backslash: