Try that:

rule XYZ
when
    $p : Process( $name : name )
    Number( $count : intValue) from accumulate(
                 $i : Process( name == $name, this != $p ),
                  count( $i ) )
then
   System.out.println( "There are "+$count+" instances of processes named
"+$name );
end

   []s
   Edson


2008/1/29, cfili <[EMAIL PROTECTED]>:
>
>
> I am having a hard time finding an example of what I am trying to do, so
> maybe someone here could help me.  What I am trying to do is determine how
> many facts fall into the same category.
>
> My facts are 'processes' and one of their attributes is a 'name'.  My goal
> is to determine how many processes with the same name are running.  The
> problem is I do not know ahead of time the process names available, I want
> to determine that set at runtime.  Also, once I determine the count for a
> given name, I do not want to run it again for the other processes that
> fall
> in that name category.
>
> I think "from collect" is probably what I want to use here, but I am not
> sure how to grab the names in my Pattern from the fact I am currently
> iterating on.
>
> Thanks.
> --
> View this message in context:
> http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to