Look up "Conditional Element collect" in the manual. That provides example code 
for getting a list of matching facts.

For more complex tasks, there's "accumulate".

Steve


On 11 Apr 2013, at 17:51, Alex Burman <[email protected]> wrote:

> Continuing with this same example, How can I count the number of times a 
> student has received an A across all the classes?
> 
> I can get it to trigger each time a student appears in the rosters of 2 
> different teachers and that student has an A in both but I can't figure out 
> how to track it across more then that. 
> 
> 
> On Fri, Apr 5, 2013 at 4:50 AM, Stephen Masters <[email protected]> 
> wrote:
> Just thought I'd mention that I hadn't replied to this, because it looks way 
> too much like comp-sci homework. Not sure whether that's the same reason 
> others haven't replied either. ;)
> 
> A hint though to get you started. You can probably use something like...
> 
> $student: Student(grade != null) from $roster
> 
> … with a few lines before that to pick out the roster in a similar fashion.
> 
> To understand it, check out the Drools Expert manual for the "from" operator 
> for working with lists/collections.
> 
> Steve
> 
> 
> On 3 Apr 2013, at 19:59, burmanator <[email protected]> wrote:
> 
> > So the example I am working with is this:
> > You have a Teacher object
> >     that stores a list of Rosters  objects
> >           in each Roster is a list of Students objects
> >                each Student has a grade value
> >
> > How would I go about creating a rule to find all the students that got As
> > for a given Teacher across all her Rosters?
> >
> >
> >
> > --
> > View this message in context: 
> > http://drools.46999.n3.nabble.com/creating-a-rule-regarding-an-element-of-list-stored-in-an-object-in-a-list-tp4023205.html
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > [email protected]
> > https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> 
> -- 
> Sincerely,
> Alex Burman
> cell: 908-672-0198
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to