On Friday, 18 April 2014 at 20:27:20 UTC, Steven Schveighoffer wrote:
Note also that what it returns is not an array, but a lazily iterated range over the array. If you want another array, this is the code I would use:

arr.sort();
arr = arr.uniq.array();

-Steve

Out of curiosity, if the requirement was to *also* preserve ordering (eg: remove all non-first elements), how would you go at it?

[2, 1, 1, 3, 2, 3] => [2, 1, 3];

Maybe std.algorithm's `makeIndex` would help here?

Bonus points for doing it inplace.

Reply via email to