add some printing messages

This commit is contained in:
Spaghettificated 2024-07-08 07:34:39 +02:00
parent 68aefc12c5
commit f39fa514a5
2 changed files with 25 additions and 9 deletions

View File

@ -1,4 +1,4 @@
task("take over a world",todo).
task("nic",todo).
task("test task",todo).
task("sleep",done).
task("finish this",todo).
task("test task",todo).
task("przejmij wladze nad swiatem",done).

28
todo.pl
View File

@ -1,18 +1,30 @@
:- dynamic task/2.
:- dynamic requires/2.
:- dynamic idx/2.
:- discontiguous load/0.
task("take over a world", todo).
task("sleep", done).
task("finish this", todo).
task_input(X, Y) :- task(X, Y).
task_input(X, Y) :- idx(X, Task), task(Task, Y).
all_tasks(L):- findall(X, task(X, _), L).
all_tasks(L, STATE):- findall(X, task(X, STATE), L).
print_task_list([]).
print_task_list([H|T]) :- task(H,ISDONE), write(ISDONE),write(': '), write(H),nl, print_task_list(T).
list :- all_tasks(L), print_task_list(L).
print_task_list([],_).
print_task_list([H|T],N) :-
M is N+1,
retractall(idx(N, _)),
asserta(idx(N, H)),
write(N),
write(". "),
task(H,ISDONE),
write(ISDONE),
write(': '),
write(H),nl,
print_task_list(T, M).
list_all :- all_tasks(L), print_task_list(L,1).
list_all :- all_tasks(L), print_task_list(L,1).
print_list([]).
print_list([H|T]) :- write(H),nl, print_list(T).
@ -50,8 +62,12 @@ load_task(Stream) :-
load_task(Stream) :-
read(Stream, Task),
write("reading: "),
write(Task),
nl,
asserta(Task),
load_task(Stream).
load :-
open('data.pl', read, Stream),
load_task(Stream).