Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 29 18:07:25 PDT 2015


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


More information about the Digitalmars-d-learn mailing list