Top 5

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 9 10:55:45 PDT 2008


bearophile wrote:
> Matti Niemenmaa:
>> Alternatively, since foreach got the ability to take a delegate, arrays should
>> have the built-in property .reversed and then you could do foreach (a; b.reversed).
> 
> Is that a lazy operation? Another possibility is to add a (lazy) "view" (a struct plus function template), that reverses:
> 
> foreach (a; reversed(b))
> Of course you can also write that as:
> foreach (a; b.reversed())
> 
> That's a solution I use in my code.
> 
> Bye,
> bearophile

http://www.digitalmars.com/d/2.0/phobos/std_iterator.html#retro

Andrei



More information about the Digitalmars-d mailing list