diff --git a/todo.pl b/todo.pl index c2cb4a6..f8263de 100644 --- a/todo.pl +++ b/todo.pl @@ -32,15 +32,28 @@ new(X) :- asserta(task(X, todo)), write("added task "), write(X). +check(X) :- idx(X, Task), check(Task). check(X) :- task(X, todo), + \+ (requires(Y, X), task(Y,todo)), asserta(task(X, done)), retractall(task(X, todo)), write("marked "), write(X), - write(" as done"). -check(X) :- idx(X, Task), check(Task). - + write(" as done"), + !. +check(X) :- + task(X, todo), + (requires(Y, X), task(Y,todo)), + write("you need to do "), + write(Y), + write(" before doing "), + write(X), + !. +check(X) :- + \+ task(X, todo), + write("no such task as "), + write(X). save_task(Task, Stream) :- task(Task, State),