Ad
Code
Diff
  • def unique_iterator(iterable):
      last = None
      for x in iterable:
        if x != last:
          yield x
          last = x
    
    def unique_in_order(iterable):
      return list(unique_iterator(iterable))
    • def unique_iterator(iterable):
    • last = None
    • for x in iterable:
    • if x != last:
    • yield x
    • last = x
    • def unique_in_order(iterable):
    • iterable = list(iterable)
    • while 1==1:
    • for x in range(len(iterable)):
    • if iterable[x]==iterable[x-1]:
    • del iterable[x]
    • break
    • if x==len(iterable)-1:
    • return iterable
    • return list(unique_iterator(iterable))