Hi,

N.B. to all: there's been a recent trend of CC-ing me on every message
that goes to the list. Please don't do this; I am a list subscriber too.


Anyway, you match a given position in a multifield just by putting
multiple variables into the slot - i.e.,

(defrule foo
  (status (conditions ? ? ?x $?))
 ...

will bind ?x to the third entry in the multislot. Here I've used blank
variables for the first and last entries since I don't care what they
are. 

Now, if you don't know the position until runtime, then you can't
really use matching like this. You can use 'test' this way:


(defrule foo
  (important-condition ?index)        
  (status (conditions $?x))
  (test (eq YES (nth $?x ?index)))
  =>

this lets you test the ?index-th element of the conditions.




By the way, I can't quite figure out what the rule below is supposed
to do, but note that it will only match 'status' facts with just one
element in the conditions slot (because you use a single variable to
match it.) If you want to match all contents of a multislot, you have
to use a multifield variable ($?conditions) .



I think Raghavendra Jagirdar wrote:
> Hello Jess users;
> 
> Any body knows how to use 'test' function for a specific nth$ string in 
> multislot.
> 
> example:
> 
> (deftemplate status (multislot conditions))
> 
> (defrule .......
> ?f1 (status (conditions ?conditions))
> =>
> (bind ?conditions (create$ (read)))
> ......
>   (assert (status (conditions ?conditions)))
> )
> 
> Say, the asserted values  in condition are (YES NO NO YES ...)
> 
> In another rule, I wanted to do certain actions based on the values, and its 
> position in condition. For this I wanted to use
> 'test' functionality by comparing the value and its position.
> 
> Or can I achieve this by some other means.
> 
> Thank you in advance
> Raghavendra
> 
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.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]
> ---------------------------------------------------------------------
> 



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