This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -3,11 +3,10 @@ import std.stdio, std.algorithm, std.array, std.range;
T[] mergeSorted(T)(in T[] D) /*pure nothrow*/ {
if (D.length < 2)
return D.dup;
return [D[0 .. $ / 2].mergeSorted(), D[$ / 2 .. $].mergeSorted()]
.nWayUnion().array();
return [D[0 .. $ / 2].mergeSorted, D[$ / 2 .. $].mergeSorted]
.nWayUnion.array;
}
void main() {
auto a = [3, 4, 2, 5, 1, 6];
writeln(a.mergeSorted());
[3, 4, 2, 5, 1, 6].mergeSorted.writeln;
}