implement requirements for checking a task.

This commit is contained in:
Spaghettificated 2024-07-08 12:09:15 +02:00
parent e05096734e
commit 88c2ae30f7

19
todo.pl
View File

@ -32,15 +32,28 @@ new(X) :-
asserta(task(X, todo)),
write("added task "),
write(X).
check(X) :- idx(X, Task), check(Task).
check(X) :-
task(X, todo),
\+ (requires(Y, X), task(Y,todo)),
asserta(task(X, done)),
retractall(task(X, todo)),
write("marked "),
write(X),
write(" as done").
check(X) :- idx(X, Task), check(Task).
write(" as done"),
!.
check(X) :-
task(X, todo),
(requires(Y, X), task(Y,todo)),
write("you need to do "),
write(Y),
write(" before doing "),
write(X),
!.
check(X) :-
\+ task(X, todo),
write("no such task as "),
write(X).
save_task(Task, Stream) :-
task(Task, State),