From 88c2ae30f764012e4841184824ea250e5b23f38c Mon Sep 17 00:00:00 2001 From: Spaghettificated Date: Mon, 8 Jul 2024 12:09:15 +0200 Subject: [PATCH] implement requirements for checking a task. --- todo.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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),