[rules-users] accumulate over multiple types

Edson Tirelli tirelli at post.com
Sat Jul 28 14:38:31 EDT 2007


    Geoffrey,

    I don't think you need multiple patterns for this specific use case:

rule "multipleQueensHorizontal"
when
     Queen($id : id, $y : y)
     Number( $multipleQueensHorizontal : intValue )
     from accumulate( $q : Queen(id > $id, y == $y), count($q) );
then
    // do something
end

   Am I misunderstanding your use case?

   []s
   Edson


2007/7/28, Geoffrey De Smet <ge0ffrey.spam at gmail.com>:
>
> I 'd like to get the number of queens which have the same y.
>
> I used to do this with a query:
>     query "multipleQueensHorizontal"
>         Queen($id : id, $y : y);
>         Queen(id > $id, y == $y);
>     end
> And then ask the size() of it.
>
> But now I should be able to do this with the accumulate function:
>      $multipleQueensHorizontal : Integer()
>      from accumulate(
>          $q1 : Queen($id : id, $y : y);
>          Queen(id > $id, y == $y);
>        , count($q1)
>      );
>
> However, I get a parsing error on it:
>    Caused by: org.drools.rule.InvalidRulePackage: [31,37]: unknown:31:37
> Unexpected token ';'[33,6]: unknown:33:6 mismatched token:
> [@123,814:814=',',<12>,33:6]; expecting type THEN
>
> Apparently the ; in of "$q1 : Queen($id : id, $y : y);" is inacceptable?
>
> --
> With kind regards,
> Geoffrey De Smet
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070728/63893641/attachment.html 


More information about the rules-users mailing list