mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 10:54:42 +00:00
Add 1 overload to apply (#15439)
This commit is contained in:
@@ -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`).
|
||||
|
||||
Reference in New Issue
Block a user