[rules-users] creating a rule regarding an element of list stored in an object in a list

Stephen Masters stephen.masters at me.com
Thu Apr 11 13:44:17 EDT 2013


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 <alexburman at gmail.com> 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 <stephen.masters at me.com> 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 <alexburman at gmail.com> 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
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> 
> -- 
> Sincerely,
> Alex Burman
> cell: 908-672-0198
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130411/5bbaddfa/attachment.html 


More information about the rules-users mailing list