Ranges, constantly frustrating

Ali Çehreli acehreli at yahoo.com
Tue Feb 11 09:11:46 PST 2014


On 02/11/2014 06:25 AM, Rene Zwanenburg wrote:
> On Tuesday, 11 February 2014 at 10:10:27 UTC, Regan Heath wrote:

>>   foreach (i, line; range.take(4))  //Error: cannot infer argument types
>>   {
>>     ..etc..
>>   }

> foreach (i, line; iota(size_t.max).zip(range.take(4)))
> {
>
> }

There is also the following, relying on tuples' automatic expansion in 
foreach:

     foreach (i, element; zip(sequence!"n", range.take(4))) {
         // ...
     }

Ali



More information about the Digitalmars-d-learn mailing list