<br>&nbsp;&nbsp; Sorry, my previous suggestion will count the same process name multiple times. There are a few ways to avoid it. I would probably use a helper fact:<br><br><pre class="code" id="codemain">rule XYZ<br>when<br>    $p : Process( $name : name )<br>
    not( ProcessCount( name == $name ) )<br>    Number( $count : intValue) from accumulate(<br>                 $i : Process( name == $name, <span class="keyword">this</span> != $p ),<br>                  count( $i ) )<br>
then<br>   System.out.println( <span class="literal">&quot;There are &quot;</span>+$count+<span class="literal">&quot; instances of processes named &quot;</span>+$name );<br>   insert( <span class="keyword">new</span> ProcessCount( $name, $count ) );<br>
end</pre><br>&nbsp;&nbsp; Hope it helps,<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2008/1/29, Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.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>&nbsp;&nbsp; Try that:<br><br>rule XYZ<br>when<br>&nbsp;&nbsp;&nbsp; $p : Process( $name : name )<br>&nbsp;&nbsp;&nbsp; Number( $count : intValue) from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $i : Process( name == $name, this != $p ),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count( $i ) )<br>

then<br>&nbsp;&nbsp; System.out.println( &quot;There are &quot;+$count+&quot; instances of processes named &quot;+$name );<br>end<br>&nbsp;<br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><br><div><span class="gmail_quote">2008/1/29, cfili &lt;<a href="mailto:cfilippelli@cerner.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">cfilippelli@cerner.com</a>&gt;:</span><div>
<span class="e" id="q_117c6335cedfbe38_1"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>I am having a hard time finding an example of what I am trying to do, so<br>maybe someone here could help me.&nbsp;&nbsp;What I am trying to do is determine how<br>many facts fall into the same category.<br><br>My facts are &#39;processes&#39; and one of their attributes is a &#39;name&#39;.&nbsp;&nbsp;My goal<br>

is to determine how many processes with the same name are running.&nbsp;&nbsp;The<br>problem is I do not know ahead of time the process names available, I want<br>to determine that set at runtime.&nbsp;&nbsp;Also, once I determine the count for a<br>

given name, I do not want to run it again for the other processes that fall<br>in that name category.<br><br>I think &quot;from collect&quot; is probably what I want to use here, but I am not<br>sure how to grab the names in my Pattern from the fact I am currently<br>

iterating on.<br><br>Thanks.<br>--<br>View this message in context: <a href="http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html</a><br>

Sent from the drools - user mailing list archive at <a href="http://Nabble.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Nabble.com</a>.<br><br>_______________________________________________<br>
rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></span></div>
</div><span class="sg"><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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">www.jboss.com</a>
</span></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>