parent
77f836b403
commit
462bff48b2
1 changed files with 28 additions and 0 deletions
28
tests/iter/titer11.nim
Normal file
28
tests/iter/titer11.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
discard """
|
||||||
|
file: "titer11.nim"
|
||||||
|
output: '''[
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
]
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc represent(i: int): iterator(): string =
|
||||||
|
result = iterator(): string =
|
||||||
|
yield $i
|
||||||
|
|
||||||
|
proc represent(s: seq[int]): iterator(): string =
|
||||||
|
result = iterator(): string =
|
||||||
|
yield "["
|
||||||
|
for i in s:
|
||||||
|
var events = represent(i)
|
||||||
|
for event in events():
|
||||||
|
yield event
|
||||||
|
yield "]"
|
||||||
|
|
||||||
|
let s = @[1, 2, 3]
|
||||||
|
var output = represent(s)
|
||||||
|
|
||||||
|
for item in output():
|
||||||
|
echo item
|
||||||
Loading…
Add table
Add a link
Reference in a new issue