std.range.chunks is useful for iterating through a range like so:

-----
import std.range;
import std.stdio : writeln;

void main()
{
    float[] arr = [
         0.0,   0.15, 0.0, 1.0,
         0.25, -0.25, 0.0, 1.0,
        -0.25, -0.25, 0.0, 1.0,
    ];

    foreach (xyzw; arr.chunks(4))
    {
        writeln(xyzw[0]);  // write 'x'
    }
}
-----

But instead of having to use indexing for each element in the chunk,
I'd like to use separate arguments instead, like so:

    // nicer API
    foreach (x, y, z, w; arr.chunks(4))
    {
        writeln(x);
    }

Is there a function in Phobos that does this?

Reply via email to