Why is std.algorithm so complicated to use?
Daniel Murphy
yebblies at nospamgmail.com
Tue Jul 10 10:23:40 PDT 2012
"Jacob Carlborg" <doob at me.com> wrote in message
news:jthnlo$2tjg$1 at digitalmars.com...
> On 2012-07-10 18:42, Daniel Murphy wrote:
>> "Jacob Carlborg" <doob at me.com> wrote in message
>> news:jthlpf$2pnb$1 at 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.
More information about the Digitalmars-d
mailing list