Logo

Programming-Idioms

  • Clojure
(distinct x)
#include <string>
#include <unordered_set>
#include <vector>
std::vector<std::string> x = {"one", "two", "two", "one", "three"};
std::unordered_set<std::string> t;
for (auto e : x)
    t.insert(e);

Original order is lost.
t contains the new list of unique objects.

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