Remember that the top-level lists on the left-hand-side of a rule are "conditional elements", and *not* function calls. Your "call" line is trying to match a fact with head "call", whose first slot is the same object as ?evildoers.watchedNames, and whose next two slots are the symbol "contains" and the String "Dr. Evil". You can write your rule using a "test" conditional element, like this:

(defrule person-on-evildoer-watchlist

         ?evildoers <- (Watchlist {category == "evildoers"})
         (test (?evildoers.watchedNames contains "Dr. Evil"))
=>
        (printout t "Suspicious!")
)

Note that I've left off "call", as it's always optional.


On May 5, 2009, at 3:54 AM, Henschel, Jörg wrote:

Hi all,

I'm just starting out with Jess here and I'm unsure how to access Fact members

I have a simple JavaBean containing an ArrayList and defined that with
"(deftemplate Watchlist (declare (from-class Watchlist)))"

After inserting the Fact I'd like to use a rule to check if the ArrayList contains a value:

(defrule person-on-evildoer-watchlist

         ?evildoers <- (Watchlist {category == "evildoers"})
         (call ?evildoers.watchedNames contains "Dr. Evil")
=>
        (printout t "Suspicious!")
)

Even though the "watchedNames" ArrayList does contain the specified value, the rule does not fire. It does fire when I comment out the "call" function, so I suspect I'm doing something wrong when checking the contents of the List.

Could you point me in the right direction here?

Thanks,
Jörg Henschel


--------------------------------------------------------------------
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          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            [email protected]
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].
--------------------------------------------------------------------

Reply via email to