Skip to content

Commit

Permalink
Iter test: closes nim-lang#3819 (nim-lang#9272)
Browse files Browse the repository at this point in the history
  • Loading branch information
narimiran authored and krux02 committed Oct 15, 2018
1 parent cefe90d commit 60f307a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/iter/titer11.nim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 60f307a

Please sign in to comment.