bearophile, el 18 de mayo a las 11:19 me escribiste: > Leandro Lucarella: > > > > foreach(i, elem; retro(someArray)) {} > > > > Python has an "enumerate" function exactly for this. > > Not exactly for that. To have something like that you need something more > (reversed is lazy): > > >>> iterable = "abcd" > >>> for i, elem in enumerate(reversed(iterable)): > ... print i, elem > ... > 0 d > 1 c > 2 b > 3 a
That's exactly what I was saying, you removed the context of my message. In D2 that would be: foreach (i, elem; enumerate(retro(someArray))) {} -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------------