foreach(r; requests) { r.concider(); }

bearophile bearophileHUGS at lycos.com
Wed Oct 12 02:42:52 PDT 2011


Gor Gyolchanyan:

> no, yours will print
> 1
> 0
> 0
> 
> mine will print
> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
> ...
> 100

With DMD 2.055 this code:

import std.stdio, std.range;

void printRange(Range)(Range range) {
    foreach (r; range)
        writeln(r);
}

void main() {
    printRange(iota(100));
}

Prints:

0
1
2
...
97
98
99

Bye,
bearophile


More information about the Digitalmars-d mailing list