This commit is contained in:
ryuga4 2019-05-27 22:58:09 +02:00
commit 27d0d019ca

87
expert.pl Normal file
View File

@ -0,0 +1,87 @@
pref(P,X) :-
nb_current(P,_),
nb_getval(P,Y),
( Y = X
; ( Y = nie(Z), Z \= X)),
!.
pref(P,X) :-
format("~w:\n", [P]),
read(Y),
nb_setval(P,Y),
( Y = X
; ( Y = nie(Z), Z \= X)).
termin(XS) :-
nb_current(termin,_),
nb_getval(termin,Y),
member(X,XS),
( (Y1-Y2 = Y, X >= Y1, X =< Y2)
; (nie(Y1-Y2) = Y, (X < Y1 ; X > Y2))
),
!.
termin(XS) :-
format("termin (od-do):\n"),
read(Y),
nb_setval(termin,Y),
member(X,XS),
( (Y1-Y2 = Y, X >= Y1, X =< Y2)
; (nie(Y1-Y2) = Y, (X < Y1 ; X > Y2))
),
!.
cena(X) :-
nb_current(cena,_),
nb_getval(cena,Y),
X=<Y.
cena(X) :-
format("maksymalna cena:\n"),
read(Y),
nb_setval(cena, Y),
X =< Y.
wakacje(zakopane) :-
pref(kraj,polska),
pref(teren,gory),
cena(2000).
wakacje(hawaje) :-
termin([6,7,8]),
pref(kraj, usa),
pref(teren, morze),
cena(8000).
clear :-
forall(member(A, [kraj,teren, termin, cena]), nb_delete(A)).
wakacje2(X) :-
( (wakacje(X), clear) ; (clear, fail)).