-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassistant.pl
27 lines (20 loc) · 857 Bytes
/
assistant.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
patient_symptom(anna,fatigue).
patient_symptom(anna,indigestion).
patient_symptom(anna,abdominal_pain).
patient_symptom(anna,breathing_problems).
patient_symptom(jim,cough).
patient_symptom(jim,fever).
patient_symptom(jim,chills).
patient_symptom(kate,chills).
patient_symptom(kate,fatigue).
patient_symptom(kate,cough).
patient_symptom(kate,fever).
patient_symptom(kate,headache).
:- include('diseases.pl').
% possible symptoms
symptoms([abdominal_pain,breathing_problems,chills,cough,fatigue,fever,headache,indigestion]).
list_length([],0).
list_length([H|T], L+1) :- list_length(T,L).
number_of_possible_symptoms(L) :- list_length(A, K), symptoms(A), L is K.
ask_about_symptoms(0).
ask_about_symptoms(N) :- N>0, write('Do you have '), symptoms(A), nth1(N,A,X), write(X), write('?'), nl, M is N-1, ask_about_symptoms(M).