[WORK] groupBy is in! Next: aggregate

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 24 20:41:54 PST 2015


On 1/23/15 7:30 PM, bearophile wrote:
> H. S. Teoh:
>
>> What you describe could be an interesting candidate to add, though. It
>> could iterate over distinct values of the predicate, and traverse the
>> forward range (input ranges obviously can't work unless you allocate,
>> which makes it no longer lazy) each time. This, however, has O(n*k)
>> complexity where k is the number of distinct predicate values.
>
> Let's allocate, creating an associative array inside the grouping
> function :-)
>
> Bye,
> bearophile

All languages I know do this for `group by` (because of the complexity 
involved), and I think it's ok to do so.


More information about the Digitalmars-d mailing list