mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
sequtils: Complete mapIt documentation example
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user