PROLOG: “Syntax error: Operator expected” -
i cannot figure out what's problem in code. please me out. error:
error: c:/users/ahmed/downloads/test.pl:2:4: syntax error: operator expected % c:/users/ahmed/downloads/test.pl compiled 0.00 sec, 21 clauses
here code:
domains disease,indication = symbol patient,name = string predicates hypothesis(string,disease) symptom(name,indication) response(char) go clauses go :- write("what patient's name? "), readln(patient), hypothesis(patient,disease), write(patient,"probably has ",disease,"."),nl. go :- write("sorry, don't seem able to"),nl, write("diagnose disease."),nl. symptom(patient,fever) :- write("does ",patient," have fever (y/n) ?"), response(reply), reply='y'. symptom(patient,rash) :- write("does ",patient," have rash (y/n) ?"), response(reply), reply='y'. symptom(patient,headache) :- write("does ",patient," have headache (y/n) ?"), response(reply), reply='y'. symptom(patient,runny_nose) :- write("does ",patient," have runny_nose (y/n) ?"), response(reply), reply='y'. symptom(patient,conjunctivitis) :- write("does ",patient," have conjunctivitis (y/n) ?"), response(reply), reply='y'. symptom(patient,cough) :- write("does ",patient," have cough (y/n) ?"), response(reply), reply='y'. symptom(patient,body_ache) :- write("does ",patient," have body_ache (y/n) ?"), response(reply), reply='y'. symptom(patient,chills) :- write("does ",patient," have chills (y/n) ?"), response(reply), reply='y'. symptom(patient,sore_throat) :- write("does ",patient," have sore_throat (y/n) ?"), response(reply), reply='y'. symptom(patient,sneezing) :- write("does ",patient," have sneezing (y/n) ?"), response(reply), reply='y'. symptom(patient,swollen_glands) :- write("does ",patient," have swollen_glands (y/n) ?"), response(reply), reply='y'. hypothesis(patient,measles) :- symptom(patient,fever), symptom(patient,cough), symptom(patient,conjunctivitis), symptom(patient,runny_nose), symptom(patient,rash). hypothesis(patient,german_measles) :- symptom(patient,fever), symptom(patient,headache), symptom(patient,runny_nose), symptom(patient,rash). hypothesis(patient,flu) :- symptom(patient,fever), symptom(patient,headache), symptom(patient,body_ache), symptom(patient,conjunctivitis), symptom(patient,chills), symptom(patient,sore_throat), symptom(patient,runny_nose), symptom(patient,cough). hypothesis(patient,common_cold) :- symptom(patient,headache), symptom(patient,sneezing), symptom(patient,sore_throat), symptom(patient,runny_nose), symptom(patient,chills). hypothesis(patient,mumps) :- symptom(patient,fever), symptom(patient,swollen_glands). hypothesis(patient,chicken_pox) :- symptom(patient,fever), symptom(patient,chills), symptom(patient,body_ache), symptom(patient,rash). hypothesis(patient,measles) :- symptom(patient,cough), symptom(patient,sneezing), symptom(patient,runny_nose). response(reply) :- readchar(reply), write(reply),nl.
you're using swi-prolog, follows edinburgh syntax. code looks code visual prolog, follows different syntax rules. need port code edingburgh syntax if want run under swi-prolog. otherwise, can install visual prolog , run code there.
Comments
Post a Comment