Certainly. And while containsAll may work, mattering the size and nature of the collections involved (linear vs constant time existence check) it might not perform as well as your first solution.
--- On Wed, 9/2/09, Wolfgang Laun <wolfgang.l...@gmail.com> wrote: > From: Wolfgang Laun <wolfgang.l...@gmail.com> > Subject: Re: [rules-users] forall/from/eval/contains: odd DRL syntax error > To: "Rules Users List" <rules-users@lists.jboss.org> > Date: Wednesday, September 2, 2009, 11:54 AM > Certainly, and it's more to the point - > thank you! > > Nevertheless, the compiler hiccup ought to be investigated > -W > > > On Wed, Sep 2, 2009 at 5:31 PM, > Greg Barton <greg_bar...@yahoo.com> > wrote: > > Is Collection.containsAll() an > option? > > > > --- On Wed, 9/2/09, Wolfgang Laun <wolfgang.l...@gmail.com> > wrote: > > > > > From: Wolfgang Laun <wolfgang.l...@gmail.com> > > > Subject: [rules-users] forall/from/eval/contains: odd > DRL syntax error > > > To: "Rules Users List" <rules-users@lists.jboss.org> > > > Date: Wednesday, September 2, 2009, 9:58 AM > > > A rule has to > ascertain that all elements in > > > a List<ElemBoxStatus>in a > > > Collector occur in the matching BoxResponse's > > > Set<ElemBoxStatus>. There is > > > just one BoxResponse per Collector. > > > > > > This here works fine: > > > > > > > > > rule matchCollectorResponse > > > when > > > $c : Collector( $ebsList : > > > elemBoxStatusList, $gsSet : globalStatusSet ) > > > $b : BoxResponse( collector == $c, > > > globalStatusSet == $gsSet, $ebsSet : > elemBoxStatusSet ) > > > > > > forall( $ebs : ElemBoxStatus() from > > > $ebsList > > > BoxResponse( collector > == > > > $c, elemBoxStatusSet contains $ebs ) ) > > > then > > > ... > > > end > > > > > > Thinking that $ebs is already available from the > second > > > pattern ($b:...), I tried > > > > > > > > > rule matchCollectorResponse > > > when > > > $c : Collector( $ms : message, $ebsList > : > > > elemBoxStatusList, $gsSet : globalStatusSet ) > > > $b : BoxResponse( collector == $c, > > > globalStatusSet == $gsSet, $ebsSet : > elemBoxStatusSet ) > > > > > > forall( $ebs : ElemBoxStatus() from > > > $ebsList > > > eval( > $ebsSet.contains( > > > $ebs ) ) ) > > > then > > > ... > > > end > > > > > > but the compiler came back with > > > > > > Line ...:55 no viable alternative at input > '$ebs' > > > in rule matchCollectorResponse in pattern eval > > > > > > > > > Defining a suitable function isIn(...) and using this > > > within eval() produces the same result. This > > > and other experiments seems to indicate that bindings > in > > > the first pattern of forall() are not > > > passed in to an eval() later in the forall. > > > > > > > > > JIRA? > > > > > > -W > > > > > > > > > > > > -----Inline Attachment Follows----- > > > > > > _______________________________________________ > > > rules-users mailing list > > > rules-users@lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > > > > > > > > _______________________________________________ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > -----Inline Attachment Follows----- > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users