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`).