Thank you very much for this answer. It seems like 'forall' will fire the rule 
only if all the 'bag-of-items' facts are validated (i.e., if all of them have 
'item' facts with the names listed in their 'names' slot). Is that correct?

If yes, then what I am trying to do is slightly different. I do expect to have 
some of the 'bag-of-items' facts failing the validation. What I want is to act 
upon those who pass (and also, incidentally, on those who do not pass).

Is there a way to keep track of which, among all the 'bag-of-items' facts, are 
validated by the 'forall' CE?

Best,
Aurélien

ps: 'dynamic' may be a poor choice of words. I meant that the LHS had to 
dynamically adapt to the content of a fact's multislot, different from one fact 
to another

On Jul 30, 2013, at 8:21 AM, "Friedman-Hill, Ernest [via Jess]" 
<ml-node+s2305737n4654179...@n4.nabble.com> wrote:

> Not sure what "dynamic" means in this context. But you can use the "forall" 
> conditional element to implement this rule. You could read the LHS here as 
> "For all values of ?name in bag-of-items, there's a corresponding item fact." 
> 
> (defrule check-bag-valid 
>     (forall 
>         (bag-of-items (names $?    ?name   $?)) 
>         (item (name ?name))) 
>     => 
>     (printout t "The bag is valid" crlf)) 
> 
> NOTE: Like many complex Jess rules, this one won't fire unless before adding 
> your facts you've executed the "(reset)" command to asset (initial-fact). 





--
View this message in context: 
http://jess.2305737.n4.nabble.com/Dynamic-rule-matching-in-the-LHS-tp4654176p4654180.html
Sent from the Jess mailing list archive at Nabble.com.

Reply via email to