[tutor] Update assignment

This commit is contained in:
tolauwae 2025-03-30 21:56:24 +02:00
parent 39c3af4ba5
commit ca687c0136
No known key found for this signature in database
GPG key ID: 20E068EB5B132116
18 changed files with 438 additions and 14 deletions

View file

@ -0,0 +1,31 @@
:- dynamic declaration/1.
add_declaration_first(NewDecl) :-
asserta(declaration(NewDecl)).
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 :-
database,
show_declarations,
retractall(declaration(_)),
show_declarations.