A follow up question:

(tariff (type A) (keys $? ?k $?))


does "$?" match at least 1 or also 0 occurrences ?
means will the following also match with the same rule ?

(assert(tariff (type A) (keys 22 33 44 55)))
(assert(event (type A) (key 22)))

thank you
regards

Mark  

-----Urspr|ngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von [EMAIL PROTECTED]
Gesendet: Dienstag, 9. September 2003 00:37
An: [EMAIL PROTECTED]
Betreff: Re: JESS: Jess Beginner, How to verify if a value is in a list?

I think Mark Egloff wrote:
> Hello there
> 
> My next question is, how can I check if a specific value is in a list?
> The list is part of a fact.
> 
> Example:
> 
> (assert(tariff (type A) (keys 22 33 44 55)))
> (assert(event (type A) (key 33)))
> 
> How do I check if the "key" slot from fact "event" is contained in the
> "keys" list of fact "tariff"?

In a rule, one way to do this is

(defrule find-key
   (event (type A) (key ?k))
   (tarriff (type A) (keys $? ?k $?))
   =>
   ...

This will fire only for matching pairs of facts.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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