Merging one Array with Another
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 1 15:41:06 PDT 2015
On Friday, 1 May 2015 at 19:30:08 UTC, Ilya Yaroshenko wrote:
> Probably you need something like that:
>
> x = x.chain(y).sort.uniq.array;
You're right:
import std.stdio, std.algorithm, std.range;
auto x = [11, 3, 2, 4, 5, 1];
auto y = [0, 3, 10, 2, 4, 5, 1];
writeln(x.chain(y).uniq);
writeln(x.chain(y).sort.uniq);
outputs
[11, 3, 2, 4, 5, 1, 0, 3, 10, 2, 4, 5, 1]
[0, 1, 2, 3, 4, 5, 10, 11]
so why doesn't
http://dlang.org/phobos/std_algorithm_iteration.html#.uniq
say anything about need for sortness!? I expected D to be strict
here and SortedRange as input to uniq.
More information about the Digitalmars-d-learn
mailing list