make commands for adding new requirements

This commit is contained in:
Spaghettificated 2024-07-08 12:32:59 +02:00
parent 88c2ae30f7
commit cace6f9569

25
todo.pl
View File

@ -28,10 +28,35 @@ list_done :- all_tasks(L, done), print_task_list(L,1).
print_list([]). print_list([]).
print_list([H|T]) :- write(H),nl, print_list(T). print_list([H|T]) :- write(H),nl, print_list(T).
new(X) :-
task(X, todo),
write("task already exist"),
!.
new(X) :- new(X) :-
asserta(task(X, todo)), asserta(task(X, todo)),
write("added task "), write("added task "),
write(X). write(X).
new(X,Y) :- idx(Y, Task), new(X, Task).
new(X,Y) :-
asserta(task(X, todo)),
asserta(requires(X, Y)),
write("added task "),
write(X),
write(" as a subtask for "),
write(X).
depend(X,Y) :- idx(X, Task), depend(Task, Y).
depend(X,Y) :- idx(Y, Task), depend(X, Task).
depend(X,Y) :-
task(X, todo),
task(Y, _),
asserta(requires(X, Y)).
depend(X,Y) :-
task(X, done),
task(Y, _),
retractall(task(Y, _)),
asserta(task(Y, todo)),
asserta(requires(X, Y)).
check(X) :- idx(X, Task), check(Task). check(X) :- idx(X, Task), check(Task).
check(X) :- check(X) :-
task(X, todo), task(X, todo),