[WORK] groupBy is in! Next: aggregate
MattCoder via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 23 13:56:11 PST 2015
On Friday, 23 January 2015 at 18:08:30 UTC, Andrei Alexandrescu
wrote:
> So H.S. Teoh awesomely took
> https://github.com/D-Programming-Language/phobos/pull/2878 to
> completion. We now have a working and fast relational "group
> by" facility.
>
> See it at work!
>
> ----
> #!/usr/bin/rdmd
>
> void main()
> {
> import std.algorithm, std.stdio;
> [293, 453, 600, 929, 339, 812, 222, 680, 529, 768]
> .groupBy!(a => a & 1)
> .writeln;
> }
> ----
>
> [[293, 453], [600], [929, 339], [812, 222, 680], [529], [768]]
Sorry if this a dumb question, but since you're grouping an array
according some rule, this shouldn't be:
[293, 453, 929, 339, 529][600, 812, 222, 680, 768]
?
Because then you have the array of "trues" and "falses" according
the condition (a & 1).
Matheus.
More information about the Digitalmars-d
mailing list