Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(distinct x)
x = x.toSet().toList();
Enum.uniq(x)
S = lists:usort(X)
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
for i := j; i < len(x); i++ {
x[i] = nil
}
x = x[:j]
y := make(map[T]struct{}, len(x))
for _, v := range x {
y[v] = struct{}{}
}
x2 := make([]T, 0, len(y))
for _, v := range x {
if _, ok := y[v]; ok {
x2 = append(x2, v)
delete(y, v)
}
}
x = x2
func deduplicate[S ~[]T, T comparable](x S) S {
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
var zero T
for i := j; i < len(x); i++ {
// Avoid memory leak
x[i] = zero
}
return x[:j]
}
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
x = x[:j]
x.unique()
x = [...new Set(x)];
x = Array.from(new Set(x));
const seen = new Set();
x = x.filter( v => {
if(seen.has(v))
return false;
seen.add(v);
return true;
});
x = x.distinct()
x = x.toSet().toList()
(remove-duplicates x)
local seen = {}
for index,item in ipairs(x) do
if seen[item] then
table.remove(x, index)
else
seen[item] = true
end
end
$x = array_unique($x);
def dedup(x):
y = []
for i in x:
if not i in y:
y.append(i)
return y
a, b, n = 0, 0, len(x)
while a != n:
if (t := x[a]) in x[(b := a + 1):]:
while b != n:
if x[b] == t:
del x[b]
n = n - 1
else:
b = b + 1
a = a + 1
x = list(set(x))
x.uniq!
x.sort();
x.dedup();
x = x.distinct
(define (remove-duplicates l)
(cond ((null? l)
'())
((member (car l) (cdr l))
(remove-duplicates (cdr l)))
(else
(cons (car l) (remove-duplicates (cdr l))))))
(remove-duplicates x)
x intersection: x asSet.
x asSet.
x = x.Distinct.ToList