impl saving require relations

This commit is contained in:
Spaghettificated 2024-07-08 14:11:59 +02:00
parent cace6f9569
commit 7e3e6f0d2b

22
todo.pl
View File

@ -80,19 +80,35 @@ check(X) :-
write("no such task as "),
write(X).
save_requirement(T1, T2, Stream) :-
requires(T1, T2),
write_canonical(Stream, requires(T1,T2)),
write(Stream, '.\n').
save_requirement_list(T2, [T1], Stream) :-
save_requirement(T1, T2, Stream).
save_requirement_list(T2,[H|T], Stream) :-
save_requirement(H, T2, Stream),
save_requirement_list(T2, T, Stream).
save_task_requirements(Task, Stream) :-
findall(X, requires(X, Task), L),
save_requirement_list(Task, L, Stream).
save_task_requirements(Task, _) :- \+ requires(_, Task).
save_task(Task, Stream) :-
task(Task, State),
write_canonical(Stream, task(Task, State)),
write(Stream, '.').
write(Stream, '.\n'),
save_task_requirements(Task, Stream).
save_task_list([Task], Stream) :-
save_task(Task, Stream).
save_task_list([H|T], Stream) :-
save_task(H, Stream),
write(Stream, '\n'),
save_task_list(T, Stream).
save :-
all_tasks(L),
open('data.pl', write, Stream),