<br> 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">"There are "</span>+$count+<span class="literal">" instances of processes named "</span>+$name );<br> insert( <span class="keyword">new</span> ProcessCount( $name, $count ) );<br>
end</pre><br> Hope it helps,<br> Edson<br><br><div><span class="gmail_quote">2008/1/29, Edson Tirelli <<a href="mailto:tirelli@post.com">tirelli@post.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Try that:<br><br>rule XYZ<br>when<br> $p : Process( $name : name )<br> Number( $count : intValue) from accumulate(<br> $i : Process( name == $name, this != $p ),<br> count( $i ) )<br>
then<br> System.out.println( "There are "+$count+" instances of processes named "+$name );<br>end<br> <br> []s<br> Edson<br><br><br><div><span class="gmail_quote">2008/1/29, cfili <<a href="mailto:cfilippelli@cerner.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">cfilippelli@cerner.com</a>>:</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. What I am trying to do is determine how<br>many facts fall into the same category.<br><br>My facts are 'processes' and one of their attributes is a 'name'. My goal<br>
is to determine how many processes with the same name are running. The<br>problem is I do not know ahead of time the process names available, I want<br>to determine that set at runtime. 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 "from collect" 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> Edson Tirelli<br> JBoss Drools Core Development<br>
Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> 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> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>