<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">cfilippelli@cerner.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>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">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">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> 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>