This is how to do it - although it's not recommended to use globals in rule conditions. (For one thing: the list must be complete before you call fireAllRules().)

global List list

rule "count from global List - but don't do it"
when
    Number( $i: intValue ) from accumulate( Person( age > 20 ) from list, count(1) )
then
    System.out.println( $i + " Persons" );
end

-W


On 6 July 2011 12:08, wendy <w.mungovan@yahoo.com> wrote:
I think normally setGlobal variables are only used when you want to be able
to call back out to the java code again. (I'm not an expert by any stretch
so please take that with a grain of salt.) So you might be able to just
insert the list.

I'm going to assume the List is really List<NombersUnTypeDefault> if that is
not true please let me know.

what about something like this?  First is collects all the
NombersUnTypeDefault that match your constraints from list then it counts
them using an accumulate function.

global java.util.List list

rule "Calcul redondance"
  when
      $i: Number() from accumulate($c: NombersUnTypeDefault()
                              from collect(NombersUnTypeDefault($code ==
"AAA", $int == 1) from list)
                              , count($c));
   then
      System.out.println($i);
end

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-and-ArrayList-tp3140821p3144161.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users