Ranges/algorithms for aggregation

"Luís "Luís
Fri Mar 21 08:57:40 PDT 2014


On Friday, 21 March 2014 at 15:38:23 UTC, bearophile wrote:
>>    Output: (aggregated and sorted on length)
>>    -------
>>    B -> [foo, bar, big]
>>    C -> [ble]
>>    A -> [begga]
>
> What is the desired output data structure? An associative array 
> of dynamic arrays? Or is a dynamic arrays of dynamic arrays of 
> 2-tuples enough?

I'm doing this for a D newbie, to teach him the range/algorithmic 
approach. The function he wrote to output the result of that 
transformation takes as an input an array of arrays (the latter), 
but he builds that input iteratively using an AA of arrays (the 
former). I asked him about that  mismatch and at the time he told 
me that "for now" he only needed the latter, suggesting he had 
other future plans where he might need the AA, but I'm not sure. 
So let's just say that the client is unclear on his requirements, 
which does happen in the real world anyway :-).

In any case, I think the hashGroupBy is what I was asking about 
:-). Neat. (did anyone actually implement it?)

I'm not sure how if "a dynamic arrays of dynamic arrays of 
2-tuples" sufficed that would help with the intermediate step, if 
we wanted to avoid the sorting step. Did you have anything in 
particular in mind there?


More information about the Digitalmars-d-learn mailing list