sequtils: Complete mapIt documentation example
This commit is contained in:
parent
81d287f758
commit
78b56bf7dc
1 changed files with 1 additions and 0 deletions
|
|
@ -388,6 +388,7 @@ template mapIt*(seq1, typ, pred: expr): expr =
|
|||
## let
|
||||
## nums = @[1, 2, 3, 4]
|
||||
## strings = nums.mapIt(string, $(4 * it))
|
||||
## assert strings == @["4", "8", "12", "16"]
|
||||
var result {.gensym.}: seq[typ] = @[]
|
||||
for it {.inject.} in items(seq1):
|
||||
result.add(pred)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue