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

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Wed Oct 12 01:53:59 PDT 2011


no, yours will print
1
0
0

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

On Wed, Oct 12, 2011 at 12:46 PM, bearophile <bearophileHUGS at lycos.com> wrote:
> Gor Gyolchanyan:
>
>> 4. Allow foreach loops with a single iterator to be specified without
>> a body, in which case it would return an input range (or some other
>> type of range), lazily evaluating and returning the iterator.
>>     void printRange(Range)(Range range) { foreach(r, range) {  writeln(r); } };
>>     unittest { printRange(foreach(i; 0..100)); }
>
> Is this the same?
>
> unittest { printRange(std.range.iota(100)); }
>
> Bye,
> bearophile
>


More information about the Digitalmars-d mailing list