Advertisement
Guest User

Untitled

a guest
Oct 1st, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.35 KB | None | 0 0
  1. predicates
  2.     patient(integer,symbol,symbol,integer).
  3.     illness(symbol,symbol).
  4.     medcard(integer,integer,symbol,symbol,symbol).
  5.  
  6.     question1(symbol).
  7.     question2(integer).
  8.     question3(symbol). 
  9.     question4(symbol,integer,integer).
  10.  
  11. clauses
  12.     patient(1, ivanov, m, 1955).
  13.     patient(2, petrov, m, 1956).
  14.     patient(3, sidorov, m, 1975).
  15.     patient(4, sharova, f, 1975).
  16.     patient(5, gepner, m, 1959).
  17.     patient(6, komov, m, 1989).
  18.  
  19.     illness(cold, cough).
  20.     illness(flu, temperature).
  21.     illness(cancer, tumor).
  22.     illness(diarrhea, "loose stools").
  23.     illness(alopecia, baldness).
  24.  
  25.     medcard(1, 2000, cold, "hot tea", bykov).
  26.     medcard(2, 2001, alopecia, regain, lobanov).
  27.     medcard(3, 2002, flu, antibiotic, bykov).
  28.     medcard(4, 2004, diarrhea, "activated carbon", lobanov).
  29.     medcard(5, 2005, cancer, chemotherapy, bykov).
  30.     medcard(6, 2006, cancer, chemotherapy, lobanov).
  31.  
  32.     question1(X):-
  33.         patient(Z,X,_,_),
  34.         medcard(Z,_,I,_,_),
  35.         illness(I,Res),
  36.         write(Res), nl, fail.
  37.  
  38.     question2(A):-
  39.         patient(N,F,_,IA),
  40.         2018 - A > Ia,
  41.         medcard(N, _, Ill,_,_),
  42.         write(F), write(" "), write(Ill), nl, fail.
  43.  
  44.     question3(P):-
  45.         patient(N,P,_,_),
  46.         medcard(N,_,Ill,_,_),
  47.         medcard(AN,_,Ill,_,_),
  48.         patient(AN,Res,_,_),
  49.         P<>Res,
  50.         write(Res), nl, fail.
  51.  
  52.     question4(D,F,T):-
  53.         medcard(N,Y,_,_,D),
  54.         Y > F, Y < T,
  55.         patient(N,Res,_,_),
  56.         write(Res), nl, fail.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement