Ranges, constantly frustrating

Regan Heath regan at netmail.co.nz
Wed Feb 12 02:43:52 PST 2014


On Tue, 11 Feb 2014 17:11:46 -0000, Ali Çehreli <acehreli at yahoo.com> wrote:

> 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))) {
>          // ...
>      }

Thanks for the workarounds.  :)  Both seem needlessly opaque, but I  
realise you're not suggesting these are better than the original, just  
that they actually work today.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list