<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Wolfgang<br><br>I tried both using collect and accumulate and they both worked as you suggested.<br><br>&nbsp;&nbsp;&nbsp;&nbsp; ArrayList( $total : size&gt;0 ) from collect ( Asset())<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; Number ($total:intValue ) from accumulate ($asset:Asset() ,count($asset))&nbsp; <br><br>Thanks,<br><br>Ram<br><br><br><br><br><br><br>--- On <b>Sat, 9/3/11, Wolfgang Laun <i>&lt;wolfgang.laun@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Wolfgang Laun &lt;wolfgang.laun@gmail.com&gt;<br>Subject: Re: [rules-users] How to count number of facts of a type in memory?<br>To: "Rules Users List" &lt;rules-users@lists.jboss.org&gt;<br>Date: Saturday, September 3, 2011, 9:47 PM<br><br><div class="plainMail">2011/9/4 puja nandamuri &lt;<a
 ymailto="mailto:med_9501@yahoo.com" href="/mc/compose?to=med_9501@yahoo.com">med_9501@yahoo.com</a>&gt;<br>&gt;<br>&gt; I tried to create the following rule using a simple drl to just count the number of Asset facts in memory.<br>&gt; An Asset can be a very simple class. I am not sure if the fields or methods are really relevant in this rule.<br>&gt;<br>&gt; rule " Count number of Assets Rule"<br>&gt; dialect "mvel"<br>&gt; when<br>&gt; asset:Asset()<br>&gt; ArrayList($total:size &gt;0) &nbsp;from collect ( asset)<br><br>The first operand of collect is a pattern, not a bound variable. Therefore, use<br><br>&nbsp; &nbsp; ArrayList($total:size &gt;0)&nbsp; from collect ( Asset() )<br><br>Just for counting, accumulate would also be possible:<br><br>&nbsp;&nbsp;&nbsp;Number( $total: intValue ) from accumulate( Assert(), count(1) )<br><br>-W<br><br><br>&gt; then<br>&gt; System.out.println(" Number of Assets in memory"+total);<br>&gt; end<br>&gt; This fails.
 my understanding of how collect works seems to be wrong :(<br>&gt; can you please correct the mistake I might be doing here ?<br>&gt;<br>&gt;<br><br>_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=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></blockquote></td></tr></table>