std.range lockstep is not input range but opApply entity. Workarounds?

Ali Çehreli acehreli at yahoo.com
Sat Dec 29 09:58:55 PST 2012


On 12/29/2012 06:19 AM, Simen Kjaeraas wrote:

 > foreach (a; zip(A, B) ) {
 > // Use a[0] and a[1] here.
 > }
 >
 > There have been suggestions to better integrate tuples in the language,
 > so in the future zip may have all the advantages of lockstep (and vice
 > versa), but don't cross your fingers.

Tuples have already been integrated at least as much: :)

import std.stdio;
import std.range;

void main()
{
     int[] cats;
     int[] birds;

     foreach (cat, bird; zip(cats, birds)) {
         writeln(cat, bird);
     }
}

Ali



More information about the Digitalmars-d-learn mailing list