我正在使用古老的 Turbo Prolog,因为它包含在我们的课程中。为什么这个程序不起作用?
domains
disease, indication = symbol
Patient = string
Fe,Ra,He,Ch,Vo,Ru = char
predicates
hypothesis(Patient,disease)
symptom(Patient,indication,char)
response(char)
go
clauses
go:-
write("What is patient's name?"),
readln(Patient),
symptom(Patient,fever,Fe),
symptom(Patient,rash,Ra),
symptom(Patient,head_ache,He),
symptom(Patient,chills,Ch),
symptom(Patient,runny_nose,Ru),
symptom(Patient,head_ache,He),
symptom(Patient,vomit,Vo),
hypothesis(Patient,Disease),
write(Patient," probably has ", Disease , "."),nl.
go:-
write("Sorry unable to seem to be diagnose disease"),nl.
symptom(Patient,Fever,Feedback) :-
Write("Does " , Patient , " have " , Fever , "(y/n) ?"),
response(Reply),
Feedback = Reply.
hypothesis(Patient, chicken_pox) :-
Fe = Ra = He = Ch = 'y'.
hypothesis(Patient, caner) :-
Ru = Ra = He = Vo = 'y'.
hypothesis(Patient, measles) :-
Vo = Ra = Ch = Fe = He = 'y'.
response(Reply):-
readchar(Reply),
write(Reply),nl.
我得到警告变量仅用于包含symtoms
. 参数传递不是引用调用吗?当我传递Fe
的symptoms
值应该被复制到Fe
并且当我在假设中比较它时它应该相应地工作。=
Turbo Prolog 中的运算符的工作方式非常奇怪。当它没有绑定到任何变量时,该语句a = 3
会将 3 分配给 a,当 a 已经包含一个值时,a = 5
将检查 a 的值是否为 5。
请帮助我为什么程序不起作用?
提前致谢 :)