Ranges/algorithms for aggregation

bearophile bearophileHUGS at lycos.com
Fri Mar 21 08:38:20 PDT 2014


Luís Marques:

> Is there a neat way to do this transformation with ranges and 
> std.algorithms?
>
>     Input:
>     -------
>     B foo
>     B bar
>     C ble
>     B big
>     A begga
>
>     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?

There are various ways to solve your problem.

Related:
https://d.puremagic.com/issues/show_bug.cgi?id=5968
https://d.puremagic.com/issues/show_bug.cgi?id=9842

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list