From 6b3654c48de4b0c431e1bfaad6d34ec3e33df026 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Thu, 1 Oct 2020 04:22:22 -0300 Subject: [PATCH] Add 1 overload to apply (#15439) --- lib/pure/collections/sequtils.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index d8ea3ad1fa..803f89cc57 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`).