jastrachan | 9 Mar 03:53 2005
Picon

Re: More on Sets/Lists

On 8 Mar 2005, at 13:50, Furash Gary wrote:
> Well, since we're talking about it (or me and the other guy are), let 
> me continue my digression on cool-list features of ABAP.
>  
> You can say:
>     x has fields a,b,c (like a VB struct)
>      x is a list of things
>  
>     x.sum(a="5", b = "3");
>     at this point, x.c has the sum of all rows where a=5 and b=3.  
> Kind of nifty.

FWIW it'd be fairly easy to have a sum method groovy

x.sum { it.a=="5" && it.b=="3" }

as we already have a count method

x.count { it.a=="5" && it.b=="3" }

though you can always do it the long-hand way

def sum = 0
x.each { if (it.a=="5" && it.=="3") sum++ }

James
-------
http://radio.weblogs.com/0112098/


Gmane