How about

(defrule find_it2
   (things (Id ?pId)(elements $? ?elementName $?))
   (otherthing (one_Element ?elementName))
   =>
   (printout t "found it:" ?pId crlf))

which is described at the end of 6.4. Matching in Multislots 
<http://herzberg.ca.sandia.gov/jess/docs/70/rules.html#multimatch>?

Bob Kirby

At 09:15 AM 11/14/2007, Jason Morris wrote:
>Hi Hans,
>
>Try this solution:
>
>(clear)
>(watch all)
>
>(deftemplate things
>   (slot Id)
>   (multislot elements))
>(deftemplate otherthing
>     (slot one_Element))
>
>(deffacts init
>    (things (Id 1) (elements a b c)) 
>    (otherthing (one_Element a)))
>
>;Get all Ids of things
>;Where AElement of elements equals one_Element
>
>(defrule find_it
>   (things (Id ?pId)(elements $?elements))
>   (otherthing (one_Element ?foo&:(member$ ?foo ?elements))) 
> =>
>   (printout t crlf "Found it: " ?pId crlf crlf))
>
>; Program
>(reset)
>(run)
>
>/** OUTPUT
>MAIN::find_it: +1+1+1+1+2+t
> ==> Focus MAIN
> ==> f-0 (MAIN::initial-fact)
> ==> f-1 (MAIN::things (Id 1) (elements a b c))
> ==> f-2 (MAIN::otherthing (one_Element a))
>==> Activation: MAIN::find_it :  f-1, f-2
>FIRE 1 MAIN::find_it f-1, f-2
>
>Found it: 1
>
> <== Focus MAIN 
>**/
>
>Cheers,
>Jason
>
>-----------------------------------------------------------
>Jason Morris
>Morris Technical Solutions LLC
><http://www.morris-technical-solutions.com>http://www.morris-technical-solutions.com
> 
>
>On Nov 14, 2007 10:43 AM, sotski <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> 
>wrote:
>
>Hey all!
>I have a newbie question. I read the Answers to the "matching in two
>multislots of two different templates" post.
>I have very similiar problem but not the same ;-) I simplify the problem for 
>you:
>;;Templates:
>(deftemplate things
>   (slot Id)
>   (multislot elements))
>(deftemplate otherthing
>     (slot one_Element))
>
>now I want to write a rule which does the following:
>
>get all Ids of things 
>where AElement of elements equals one_Element
>
>I wrote a rule:
>
>(defrule find_it
>   (things (Id ?pId)(elements $?elementName))
>   (otherthing (one_Element ?foo))
>   (test (eq ($?elementName ?foo)) 
> =>
>   (printout t "found it:" ?pId crlf))
>
>But it doesen't fire.
>I assert facts from java and they are of type RU.SYMBOL
>
>Thx for your help
>Bye
>Hans
>--
>View this message in context: 
><http://www.nabble.com/matching-problem-tf4805951.html#a13749159>http://www.nabble.com/matching-problem-tf4805951.html#a13749159
>Sent from the Jess mailing list archive at <http://Nabble.com>Nabble.com.
>
>--------------------------------------------------------------------
>To unsubscribe, send the words 'unsubscribe jess-users <mailto:[EMAIL 
>PROTECTED]>[EMAIL PROTECTED]'
>in the BODY of a message to <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED], NOT 
>to the list
>(use your own address!) List problems? Notify <mailto:[EMAIL PROTECTED]>[EMAIL 
>PROTECTED]
>-------------------------------------------------------------------- 
>
>
>
>

Reply via email to