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) :- idx(Y, Task), new(X, Task).
new(X,Y) :- new(X,Y) :-
asserta(task(X, todo)), asserta(task(X, todo)),
asserta(requires(X, Y)), asserta(requires(X, Y)),
uncheck(X),
write("added task "), write("added task "),
write(X), write(X),
write(" as a subtask for "), write(" as a subtask for "),
@ -52,10 +53,11 @@ depend(X,Y) :-
asserta(requires(X, Y)). asserta(requires(X, Y)).
depend(X,Y) :- depend(X,Y) :-
task(X, done), task(X, done),
task(Y, _), task(Y, todo),
retractall(task(Y, _)), uncheck(X).
asserta(task(Y, todo)), depend(X,Y) :-
asserta(requires(X, Y)). task(X, done),
task(Y, done).
check(X) :- idx(X, Task), check(Task). check(X) :- idx(X, Task), check(Task).
check(X) :- check(X) :-
@ -75,11 +77,33 @@ check(X) :-
write(" before doing "), write(" before doing "),
write(X), write(X),
!. !.
check(X) :-
task(X, done),
write("the task is already done "),
!.
check(X) :- check(X) :-
\+ task(X, todo), \+ task(X, todo),
write("no such task as "), write("no such task as "),
write(X). 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) :- save_requirement(T1, T2, Stream) :-
requires(T1, T2), requires(T1, T2),
write_canonical(Stream, requires(T1,T2)), write_canonical(Stream, requires(T1,T2)),