Super-dee-duper D features

kris foo at bar.com
Tue Feb 13 15:50:44 PST 2007


kris wrote:
> Bill Baxter wrote:
> 
>> Frits van Bommel wrote:
>>
>>> By the way, would the new loop syntax allow more than two collections 
>>> to be simultaneously iterated?
>>
>>
>>
>> Whoa!  I certainly hope so.  It hadn't even occurred to me that Andrei 
>> might mean this syntax can only be used for just two collections.  If 
>> that's the case then ... ick.
>>
>> --bb
> 
> 
> InterleavedIterator does multiple collections via using multiple 
> instances of InterleavedIterator. It's simple to use, and only needs to 
> be written once. Would be better to implement some basic iterator needs 
> than to introduce some tricky new syntax?
> 
> - Kris


Should have given an example. Simple case with 2 entities:

auto two = InterleavedInterator (x, y);
foreach (x; two) ...

more than 2:

auto three = InterleavedInterator (two, z);
foreach (x; three) ...



More information about the Digitalmars-d mailing list