Checkpoint
This commit is contained in:
parent
5bfa1691dd
commit
a85169dced
27 changed files with 377 additions and 250 deletions
|
@ -1,27 +1,32 @@
|
|||
% choice(X) :- X = 1, !; X = 2.
|
||||
grade(alice, a).
|
||||
grade(bob, b).
|
||||
grade(carol, a).
|
||||
grade(dave, c).
|
||||
:- dynamic declaration/1.
|
||||
|
||||
got_an_a(Student) :-
|
||||
grade(Student, Grade),
|
||||
Grade = a.
|
||||
add_declaration_first(NewDecl) :-
|
||||
asserta(declaration(NewDecl)).
|
||||
|
||||
did_not_get_an_a(Student) :-
|
||||
grade(Student, Grade),
|
||||
Grade \= a.
|
||||
add_declaration_last(NewDecl) :-
|
||||
assertz(declaration(NewDecl)).
|
||||
|
||||
database :-
|
||||
add_declaration_first('Man is born free, and everywhere he is in chains.'),
|
||||
retract(declaration(_)),
|
||||
add_declaration_last('The revolution devours its own children.'),
|
||||
add_declaration_first('I disapprove of what you say, but I will defend to the death your right to say it.'),
|
||||
add_declaration_first('Give me Liberty, or give me Death!'),
|
||||
add_declaration_last('So this is how liberty dies, with thunderous applause.').
|
||||
|
||||
show_declarations :-
|
||||
declaration(Decl),
|
||||
write(Decl), nl,
|
||||
fail.
|
||||
|
||||
show_declarations.
|
||||
|
||||
:- initialization(main).
|
||||
|
||||
main :-
|
||||
write("While "),
|
||||
got_an_a(X),
|
||||
write(X), write(" got an A, "), fail;
|
||||
write("but "),
|
||||
did_not_get_an_a(Y),
|
||||
write(Y), write(" did not get an A, "), fail; write("unfortunately."), nl.
|
||||
database,
|
||||
show_declarations,
|
||||
retractall(declaration(_)),
|
||||
show_declarations.
|
||||
|
||||
:- initialization(main).
|
||||
main :- write('gpl zegt: '), groet(wereld), nl.
|
||||
groet(X) :- write(dag(X)).
|
||||
|
|
Reference in a new issue