impl unchecking (manually and by adding subtask)

This commit is contained in:
Spaghettificated 2024-07-08 15:17:08 +02:00
parent 7e3e6f0d2b
commit 3cc96ed39b

34
todo.pl
View File

@ -39,7 +39,8 @@ new(X) :-
new(X,Y) :- idx(Y, Task), new(X, Task).
new(X,Y) :-
asserta(task(X, todo)),
asserta(requires(X, Y)),
asserta(requires(X, Y)),
uncheck(X),
write("added task "),
write(X),
write(" as a subtask for "),
@ -52,10 +53,11 @@ depend(X,Y) :-
asserta(requires(X, Y)).
depend(X,Y) :-
task(X, done),
task(Y, _),
retractall(task(Y, _)),
asserta(task(Y, todo)),
asserta(requires(X, Y)).
task(Y, todo),
uncheck(X).
depend(X,Y) :-
task(X, done),
task(Y, done).
check(X) :- idx(X, Task), check(Task).
check(X) :-
@ -75,11 +77,33 @@ check(X) :-
write(" before doing "),
write(X),
!.
check(X) :-
task(X, done),
write("the task is already done "),
!.
check(X) :-
\+ task(X, todo),
write("no such task as "),
write(X).
uncheck(X) :- idx(X, Task), uncheck(Task).
uncheck(X):-
task(X, done),
retractall(task(X, done)),
asserta(task(X, todo)),
write("unchecked task: "),
write(X),
nl,
findall(Parent, requires(X, Parent), L),
uncheck_list(L).
uncheck_list([]).
uncheck_list([H|T]):-
task(H, todo),
uncheck_list(T).
uncheck_list([H|T]):-
uncheck(H),
uncheck_list(T).
save_requirement(T1, T2, Stream) :-
requires(T1, T2),
write_canonical(Stream, requires(T1,T2)),