Add 1 overload to apply (#15439)

This commit is contained in:
Juan Carlos
2020-10-01 04:22:22 -03:00
committed by GitHub
parent 86d7b63e2a
commit 6b3654c48d

View File

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