chunks equivalent with unpacking?

bearophile bearophileHUGS at lycos.com
Wed Jul 31 10:49:01 PDT 2013


Andrej Mitrovic:

>     foreach (x, y, z, w; arr.chunks(4))
>     {
>         writeln(x);
>     }
>
> Is there a function in Phobos that does this?

Those four variables x y z w influence the type of the foreach, 
while 4 is a run-time argument. This API can be used:

foreach (x, y, z, w; arr.chunks!4)

A forward range like that seems easy to implement.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list