I don't know If I understood well, but did you try this?

when
 $xs : ArrayList() from collect(X())
 $total : Number() from accumulate(X($c: count), sum($c))

The accumulate will iterate over all the X and calculate the sum.

Best,

On Fri, May 21, 2010 at 2:12 PM, ljnelson <ljnel...@gmail.com> wrote:

>
> I have a rule that needs to make use of the accumulate() function.
>
> It also needs the value of the first argument to the accumulate() function.
>
> Suppose there are 5 Xs in working memory, each with "count" fields.
>
> I need--in my consequence--access to (a) the list of 5 Xs, and (b) the
> result of the accumulate function having worked on them (in my case it's
> really just a simple sum, so accumulate(X($count : count), sum($count))).
>
> Naively, I tried this, having a strong and accurate supposition that it
> wasn't going to work:
>
> when
>  $xs : ArrayList() from collect(X())
>  $total : Number() from accumulate($xs, sum(count))
>
> At any rate, I hope that helps convey what I need.  My consequence needs
> the
> list of Xs the accumulate function worked on, as well as the result of the
> accumulate function (the Number).  What's the best way to accomplish this?
>
> Thanks in advance,
> Laird
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/from-accumulate-somevar-tp834882p834882.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to