Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Python
a, b, n = 0, 0, len(x)
t = None
while a != n:
    t, b = x[a], a + 1
    while b != n:
        if x[b] == t:
            del x[b]
            n = n - 1
        else: b = b + 1
    a = a + 1
def dedup(x):
  y = []
  for i in x:
    if not i in y:
      y.append(i)
  return y

Preserves order
x = list(set(x))

Doesn't preserve order
from collections import OrderedDict
x = list(OrderedDict(zip(x, x)))

Preserves order
x = list({*x})
(distinct x)

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