"Jacob Carlborg" <d...@me.com> wrote in message news:jthnlo$2tjg$1...@digitalmars.com... > On 2012-07-10 18:42, Daniel Murphy wrote: >> "Jacob Carlborg" <d...@me.com> wrote in message >> news:jthlpf$2pnb$1...@digitalmars.com... >>> >>> Can't "map" and "filter" return a random-access range if that's what >>> they >>> receive? >>> >> map can, and does. > > It doesn't seem to: > > auto a = [3, 4].map!(x => x); > auto b = a.sort; > > Result in one of the original errors I started this thread with. > > -- > /Jacob Carlborg > >
writeln([1, 2, 3].map!"a"()[2]); Sort is in place, and therefore requires more than random access, you need to be able to modify the data you're operating on. Something like [3, 4].map!func().selectionSort() could work lazily without needing to modify the original range, but urrgh.