<br>&nbsp;&nbsp; Gerald, <br><br>&nbsp;&nbsp; It is not clear if you want to calculate the sum of all integers in the original list or the sum of all integers greater than 0.<br>&nbsp;&nbsp; Assuming you want to sum all integers greater than 0, see example bellow. Adjust the example to your needs if you want something different. <br>
&nbsp;&nbsp; <br>&nbsp;&nbsp; You already know how to access the elements of a list:<br><br>Number( intValue &gt; 0 ) from $mo.getNumbers()<br><br>&nbsp;&nbsp; You already know how to collect them:<br><br>$i : ArrayList ( ) from collect ( Number( intValue &gt; 0 ) from $mo.getNumbers() )<br>
<br>&nbsp;&nbsp; If instead of collecting them, you want to &quot;accumulate&quot; them:<br><br>$total : Number() from accumulate( $n:Number( intValue &gt; 0 ) from $mo.getNumbers(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum( $n ) )<br>
<br>&nbsp; Hope it helps,<br>&nbsp; &nbsp; &nbsp; Edson <br><br><br><br><br><br><br><div><span class="gmail_quote">2008/3/13, Gerald Cantor &lt;<a href="mailto:geraldmcantor@yahoo.com">geraldmcantor@yahoo.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> I have an Object in working memory. This object has an ArrayList of Integer<br> objects. I am trying to create a rule that will count all occurrences of<br> Integers in this ArrayList that are non-zero and then calculate the sum of<br>
 all the Integers in the ArrayList and then check the total against a range.<br> <br> I understand how to count the non-zero occurrences but I am at a complete<br> loss as to how to calculate the sum of the Integer objects in the ArrayList.<br>
 <br> Here is the rule I have thus far<br> rule &quot;Rule 1&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dialect &quot;java&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mo : MyObject( )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$i : ArrayList ( ) from collect ( Number( intValue &gt; 0 ) from<br>
 $mo.getNumbers() )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$total : Number(&nbsp;&nbsp;) from accumulate ???<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Rule 1: i.size() = &quot; + $i.size());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Rule 1: total = &quot; + $total);<br>
 end<br> <br> I have been unsuccessful in finding a post that deals with how to fill in<br> the ??? portion of my rule. My apologies in advance if I happen to miss such<br> a post.<br> <br> Any help is greatly appreciated.<br>
 <br> Regards,<br> Gerald<br> <br>--<br> View this message in context: <a href="http://www.nabble.com/accumulate---sum-and-ArrayList-tp16033216p16033216.html">http://www.nabble.com/accumulate---sum-and-ArrayList-tp16033216p16033216.html</a><br>
 Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br> <br> _______________________________________________<br> rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> </blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>
&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>