[rules-users] Collect with same value

wendy w.mungovan at yahoo.com
Wed Aug 10 13:47:00 EDT 2011


thank you.



________________________________
From: Wolfgang Laun-2 [via Drools] <ml-node+3243337-1322012020-394790 at n3.nabble.com>
To: wendy <w.mungovan at yahoo.com>
Sent: Wednesday, August 10, 2011 1:31 PM
Subject: Re: [rules-users] Collect with same value


rule "get big shapes by color"
when
  $map: Map()
    from accumulate ( $shape: Shapes( $color: color, size > 5 ),
      init( Map m = new HashMap(); ),
      action( List list = m.get( $color );
                 if( list == null ) list = new ArrayList();
                 list.add( shape ); ),
      result( m ) )
then
   // process $map to get all lists of same color
end

Untested.

-W


On 10 August 2011 17:20, wendy <[hidden email]> wrote:

Hi,
> I'm trying to write the following rule but am having some trouble.
>
> We have a object say Shape and which has attributes size and color.  I
>want to get a list of all shapes with the same color that have size > 5.
>How can I make sure the color is the same for all objects in the collect
>without having different rules for 'red', 'green'...?
>
>Thank you,
>Wendy
>
>
>--
>View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3242904.html
>Sent from the Drools: User forum mailing list archive at Nabble.com.
>_______________________________________________
>rules-users mailing list
>[hidden email]
>https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________ 
rules-users mailing list 
[hidden email] 
https://lists.jboss.org/mailman/listinfo/rules-users


________________________________
 
If you reply to this email, your message will be added to the discussion below:http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3243337.html 
To unsubscribe from Collect with same value, click here.

--
View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3243377.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110810/7dedc054/attachment.html 


More information about the rules-users mailing list