diff --git a/todo.pl b/todo.pl index 910d0b3..d1a35c5 100644 --- a/todo.pl +++ b/todo.pl @@ -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),