Adds each's map alias to index.
This commit is contained in:
parent
6e65f5b49e
commit
0b078e81d0
1 changed files with 3 additions and 3 deletions
|
|
@ -1461,14 +1461,14 @@ proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} =
|
||||||
setLen(s, L)
|
setLen(s, L)
|
||||||
|
|
||||||
proc each*[T, S](data: openArray[T], op: proc (x: T): S {.closure.}): seq[S] =
|
proc each*[T, S](data: openArray[T], op: proc (x: T): S {.closure.}): seq[S] =
|
||||||
## The well-known ``map`` operation from functional programming. Applies
|
## The well-known `map`:idx: operation from functional programming. Applies
|
||||||
## `op` to every item in `data` and returns the result as a sequence.
|
## `op` to every item in `data` and returns the result as a sequence.
|
||||||
newSeq(result, data.len)
|
newSeq(result, data.len)
|
||||||
for i in 0..data.len-1: result[i] = op(data[i])
|
for i in 0..data.len-1: result[i] = op(data[i])
|
||||||
|
|
||||||
proc each*[T](data: var openArray[T], op: proc (x: var T) {.closure.}) =
|
proc each*[T](data: var openArray[T], op: proc (x: var T) {.closure.}) =
|
||||||
## The well-known ``map`` operation from functional programming. Applies
|
## The well-known `map`:idx: operation from functional programming. Applies
|
||||||
## `op` to every item in `data`.
|
## `op` to every item in `data` modifying it directly.
|
||||||
for i in 0..data.len-1: op(data[i])
|
for i in 0..data.len-1: op(data[i])
|
||||||
|
|
||||||
iterator fields*[T: tuple](x: T): TObject {.
|
iterator fields*[T: tuple](x: T): TObject {.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue