On Wed, 16 Feb 2011 22:00:13 +0100, Andrej Mitrovic wrote: > On 2/16/11, jam <gr0v3e...@gmail.com> wrote: >> void main() >> { >> auto a = [5,1,2,3,4,5,1]; >> auto index = countUntil(retro(a),5); >> writeln(a[a.length-1-index .. a.length]); >> } >> >> > That works for random-access ranges. > But I was under the impression that bidirectional ranges don't > necessarily have a length property?
Doh. That is exactly correct. I guess the following would work for bidirectional ranges: import std.stdio,std.algorithm,std.range,std.container; void main() { auto a = [5,1,2,3,4,5,1]; auto index = countUntil(retro(a),5); auto R = retro(take(retro(a),index+1)); writeln(R); R[0] = 6; writeln(a); } but this is just getting nutty.