Hi,
This code prints the arrays:
[5]
[6]
[7]

import std.stdio, std.algorithm;

static int idx;

void walk(R)(R range) {
    while (!range.empty) {
        range.front;
        range.popFront;
        ++idx;
    }
}

void main() {
    [5, 6, 7].map!(a => [a].writeln).walk;
}

How should I apply mixins to `range.front` to the program to print the arrays:
[0, 5]
[1, 6]
[2, 7]

Ie I want to get something like this:

void walk(R)(R range) {
    while (!range.empty) {
        // mixin(`[idx ~ "mixin("range.front")"[1 .. $]);`);
        range.popFront;
        ++idx;
    }
}

Can I do this?

-----
Thank you for the function `walk` Mark Isaacson of presentation DConf 2015:
http://dconf.org/2015/talks/isaacson.pdf

Reply via email to