Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • D
import std.algorithm;
import std.array;
x = x.sort.uniq.array;

uniq takes and output a range which could be infinite so it only looks for adjacent duplicates. That's why we sort x beforehand.
import std.container;
import std.array;
x = redBlackTree(x)[].array;

Converts to a set then back to an array
(distinct x)

New implementation...
< >
programming-idioms.org