From f39fa514a571e4caa0ae4fb6a4b412676cf40a1e Mon Sep 17 00:00:00 2001 From: Spaghettificated Date: Mon, 8 Jul 2024 07:34:39 +0200 Subject: [PATCH] add some printing messages --- data.pl | 6 +++--- todo.pl | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/data.pl b/data.pl index 6a1298c..e67663f 100644 --- a/data.pl +++ b/data.pl @@ -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). \ No newline at end of file +task("przejmij wladze nad swiatem",done). \ No newline at end of file diff --git a/todo.pl b/todo.pl index c445d1c..9f5d18b 100644 --- a/todo.pl +++ b/todo.pl @@ -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).