summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorJuan Carlos <juancarlospaco@gmail.com>2020-10-01 04:22:22 -0300
committerGitHub <noreply@github.com>2020-10-01 09:22:22 +0200
commit6b3654c48de4b0c431e1bfaad6d34ec3e33df026 (patch)
tree0128649f701e92f31ed55a9f2fd4bc382079ec25 /lib
parent86d7b63e2ae7177061ff13d7b4cf32ba512f22f6 (diff)
downloadNim-6b3654c48de4b0c431e1bfaad6d34ec3e33df026.tar.gz
Add 1 overload to apply (#15439)
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/sequtils.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index d8ea3ad1f..803f89cc5 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -415,6 +415,11 @@ proc apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
 
   for i in 0 ..< s.len: s[i] = op(s[i])
 
+proc apply*[T](s: openArray[T], op: proc (x: T) {.closure.}) {.inline, since: (1, 3).} =
+  ## Same as `apply` but for proc that do not return and do not mutate `s` directly.
+  runnableExamples: apply([0, 1, 2, 3, 4], proc(item: int) = echo item)
+  for i in 0 ..< s.len: op(s[i])
+
 iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T =
   ## Iterates through a container `s` and yields every item that fulfills the
   ## predicate `pred` (function that returns a `bool`).