foreach (x; a .. b) and foreach_reverse (x; a .. b) should be disallowed for floats

bearophile bearophileHUGS at lycos.com
Mon May 18 08:19:44 PDT 2009


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

Bye,
bearophile



More information about the Digitalmars-d mailing list