First class lazy Interval

downs default_357-line at yahoo.de
Sat Feb 28 02:28:43 PST 2009


Andrei Alexandrescu wrote:
> bearophile wrote:
>> As an alternative syntax may be:
>>
>> foreach (i; 1:10) {...}
>> foreach (i; 10 : 1 : -1) {...}
>> foreach (i; 0.0 : 10.5 : 0.5) {...}
> 
> I have an idea - we define a contextual keyword "iota" that helps us
> specify from, to, and stride. Then we can write:
> 
> foreach (i; iota(0.0, 10.5, 0.5)) {...}
> 
> 
> Andrei

How about the more intuitive "foreach (i; 0 .. 10.5 stride 0.5)"?

It doesn't always have to be a symbol. ^^



More information about the Digitalmars-d mailing list