On 12/03/2015 12:59 PM, Timon Gehr wrote:
On 12/03/2015 05:09 PM, Vladimir Panteleev wrote:
On Thursday, 3 December 2015 at 15:18:16 UTC, Andrei Alexandrescu wrote:
This should be pretty cool:

https://issues.dlang.org/show_bug.cgi?id=15401

Andrei

Does chain not provide random access, thus allowing sorting a chain of
two ranges?

void partialSort(R,S)(R r,S s)
     if(isRandomAccessRange!R && hasLength!R && hasSlicing!R &&
        isRandomAccessRange!S && hasLength!S && hasSlicing!S)
{ partialSort(chain(r,s),r.length); }

unittest{
     auto a=[1,2,3,4];
     auto b=[1,2,3,4,5,6];
     partialSort(a,b);
     assert(equal(a,[1,1,2,2]));
}

Yah, please convert to pull request. Using two ranges is just beautiful. Thanks! -- Andrei

Reply via email to