It would be easier to detect a depends-on where the available-part would be
missing for one of its name list elements.

As it stands now, you'll need an identifier for depends-on so that the
binding into the not (via ?x) is possible.

(defrule every-subtask
  (depends-on (id ?x)(parent ?a))
  (not (and (depends-on (id ?x)(name ? ?n ?))
            (not (available-part (name ?n)))))
   =>
  (assert (available-part (name ?a)))
)

-W


On Tue, Jul 28, 2009 at 2:47 PM, levent kent <[email protected]> wrote:

> Hi  everybody,
>
> I am doing my masters thesis and have a problem with lists.
> It is actually very simple.
>
> I want to create a rule which says:
> If all subtasks of a parent task are completed, then the parent task can be
> completed too.
>
> I tried the code below, but it seems that I can not use "foreach" at LHS of
> a rule.
>
> (defrule BuildPlanForward
>     (depends-on (parent ?a) (children ?list))
>     (foreach ?c ?list  (available-part (name ?c)))
>     =>
>     (assert (available-part (name ?a)))
>     )
>
> How could I write such a rule in Jess?
>
> Thanks,
>
> --
> Levent Kent
>

Reply via email to