Conceptually it&#39;s quite simple. Consider a loop<br><br>int sum( int[] array )<br>i = 0;                            // init<br>for( int a: array ){<br>   i += a;                     // action<br>}<br>return i;                     // result<br>
<br>Drools does the loop, calling your callbacks providing the appropriate context from the scope of the ___ in the accumulate( _____________________ ,<br><br>You could look at the implementations of the built-in accumulate functions, and you&#39;ll see the same callbacks as methods of the function provider class.<br>
<br>Just for fun: You can also use:<br><br>import java.util.Set;<br>import java.util.HashMap;<br><br>rule countById<br>when<br>    $set: Set()<br>            from accumulate( Request( $id: id ),<br>              init( HashMap id2count = new HashMap() ),<br>
              action( Integer i = (Integer)id2count.get( $id );<br>                      if( i == null ) i = 0;<br>                      i++;<br>                      id2count.put( $id, i ); )<br>              reverse( Integer i = (Integer)id2count.get( $id );<br>
                       i--;<br>                       id2count.put( $id, i ); )<br>              result( id2count.entrySet() ) )<br>    java.util.Map.Entry( $id: key, $count: value &gt; 1 ) from $set<br>then<br>    System.out.println( &quot;Id &quot; + $id + &quot;: &quot; + $count ); <br>
end<br><br>Don&#39;t worry - I wanted to research this for some time; never had an opportunity ;-)<br>-W<br><br><br><div class="gmail_quote">On 7 July 2011 17:18, Andre <span dir="ltr">&lt;<a href="mailto:morpheusandre@web.de">morpheusandre@web.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">sry if my questions are looking that &quot;nooby&quot;, that you are coding for me  i<br>
just wanna know, how this statemachine works behind this ..<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3148523.html" target="_blank">http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3148523.html</a><br>

</font><div><div></div><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>