summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2014-02-10 12:44:44 -0600
committerSimon Hafner <hafnersimon@gmail.com>2014-02-10 12:44:44 -0600
commit0b5c14962e63f3aca0c7480de2428568b4ba6650 (patch)
treebe69ed29c547005c99493cbd27e98987d96b3074 /lib
parent5d939570488706553bdb3dc58d7902e454cd6de4 (diff)
downloadNim-0b5c14962e63f3aca0c7480de2428568b4ba6650.tar.gz
added `map` to sets
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/sets.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index e6ab617e5..12fa2625b 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -241,3 +241,7 @@ proc `<=`*[A](s, t: TSet[A]): bool =
       
 proc `==`*[A](s, t: TSet[A]): bool =
   s.counter == t.counter and s <= t
+
+proc map*[A, B](data: TSet[A], op: proc (x: A): B {.closure.}): TSet[A] =
+  result = initSet[B]()
+  for i in data: result.incl(op(i))