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

Reply via email to