On Jul 23, 2008, at 6:50 PM, Ernest Friedman-Hill wrote:

The "forall" conditional element can do this:

(defrule something-like-this
   (forall (some-state (list-o-things $? ?thing-id $?))
           (thing (id ?thing-id) (state "2")))
   =>
   (do-something)
   )

This basically reads "If for all ways of matching the first pattern,
there's a match for the second pattern..."

Note one important difference: ?thing-id is not a multifield. It has
to match just one item from the list.

Yea, sorry 'bout that.  It was a typo...


Many thanks!  This is fantastic.





On Jul 23, 2008, at 8:53 PM, Hal Hildebrand wrote:

Sorry for the wacky subject line, but can't think of a good way to
describe what I'm attempting.

Suppose I had something like the following:

(deftemplate some-state (multislot list-o-things))
(deftemplate thing (slot id) (slot state (default "1")))

(defrule transition-2
   (some-state (list-o-things $? $?thing-id $?))
   ?thing <- (thing (id ?thing-id) (state "1"))
   =>
   (modify ?thing (state "2"))
   )

(defrule transition-3
   (some-state (list-o-things $? $?thing-id $?))
   ?thing <- (thing (id ?thing-id) (state "2"))
   =>
   (modify ?thing (state "3"))
   )

Note that the "some-state" fact multislot refers to the "thing" facts
indirectly, through an id - this is important, as I cannot have the
"things" embedded in the list, rather they have to be separate facts
that stand on their own.

What I would like to do is define a rule which will fire when all the
elements referred to in the multi-slot are in a particular state.
For
example, I'd like to define a rule which detects when all of the
"things" referred to in the list have "state" value of "2".  Note
that
the size of the list can vary between instances of the "some-state",
and the ids are literally UUIDs,  so I can't simply lay down a rule
which enumerates the id's of the "thing"s.

I can't for the life of me figure out how to write such a rule.
So....

a) is it possible at all...
b) what would it look like if it was possible.

Thanks for your consideration.


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]
'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
.
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
.
--------------------------------------------------------------------




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to