Skip to content

Instantly share code, notes, and snippets.

@Bennyelg
Last active February 12, 2019 21:37
Show Gist options
  • Save Bennyelg/d472cc66d3150d0bb549c14c9a17c253 to your computer and use it in GitHub Desktop.
Save Bennyelg/d472cc66d3150d0bb549c14c9a17c253 to your computer and use it in GitHub Desktop.
import sequtils
import nimpy
import tables
import intsets
proc remove_duplications_nim(n: seq[int]): seq[int] {.exportpy.} =
var t1 = initTable[int, int]()
for t in n:
discard t1.hasKeyOrPut(t, 1)
return toSeq(t1.keys())
proc remove_duplications_nim_with_sets(n: seq[int]): seq[int] {.exportpy.} =
var e = initIntSet()
var l: seq[int] = @[]
for x in n:
if not containsOrIncl(e, x):
l.add(x)
return l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment