The question is very interesting !

Could someone confirm this is the unique or the better way to use state
variables between rules ?

Thanks.

--
Ephemeris Lappis


> -----Message d'origine-----
> De : Ricardo Rojas Aguirre [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 31 janvier 2006 18:05
> À : [email protected]
> Objet : Re: [drools-user] Drools: Sharing a value between the rule's
> "condition" and "consequence" ?
> 
> Hi, I solved the same problem with a local variable defined in the
> function
> tag...
> 
> To solve your proble try somthing like this...
> <java:functions>
> 
> public static double sqrtResult;
> 
> </java:functions>
> 
> <rule name="yourRule" description="calculate sqrt">
> 
> < parameter identifier="num" >
>    < class > Integer < / class >
> < / parameter >
> 
> < java:condition >
>   (sqrtResult=Math.sqrt(num.intValue())) > 1000
> < / java:condition >
> 
> < java:consequence >
>   System.out.println( sqrtResult );
> < / java:consequence >
> 
> </rule>
> 
> Cheers
> Rik
> 
> 
> ----- Original Message -----
> From: "sol myr" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, January 31, 2006 11:04 AM
> Subject: [drools-user] Drools: Sharing a value between the rule's
> "condition" and "consequence" ?
> 
> 
> > Hi,
> >  I'm new to Drools. Could anyone please help with the following:
> >
> >  Can you share data between a rule's "condition" and "consequence" ?
> > For example:
> > - My "condition" calculates some square root (Math.sqrt)
> > - The "consequence" needs to print out the same square root
> >
> >  It's not efficient to call Math.sqrt twice... :
> >
> > < parameter identifier="num" >
> >   < class > Integer < / class >
> > < / parameter >
> > < java:condition >
> >   Math.sqrt(num.intValue()) > 1000
> > < / java:condition >
> > < java:consequence >
> >   System.out.println( Math.sqrt(num.intValue())
> > < / java:consequence >
> >
> > Is there a way to store the result of "Math.sqrt" in some temporary
> > variable ( so as to avoid the duplicate calculation ) ?
> > Please note I know about "application data", but i'd rather not use it,
> > because my sqrt is just a temporary value...
> >
> > Thanks :)
> >
> >
> > ---------------------------------
> >
> > What are the most popular cars? Find out at Yahoo! Autos


Reply via email to