yield iteration
Timon Gehr
timon.gehr at gmx.ch
Sun Jul 29 07:48:06 PDT 2012
Ideally it would look like this:
struct Map(alias fun, R){
R range;
mixin YieldInputRange!q{
for(; !range.empty; range.popFront())
yield fun(range.front);
}
static if(is(typeof(range.save))) @property auto save(){
return Map!(fun, R)(range.save);
}
...
}
Or as a built-in:
struct Map(alias fun, R){
R range;
yield {
for(; !range.empty; range.popFront())
yield fun(x);
}
static if(is(typeof(range.save))) @property auto save(){
return Map!(fun, R)(range.save);
}
...
}
More information about the Digitalmars-d
mailing list