summary refs log tree commit diff stats
path: root/tests/iter/titer11.nim
blob: c4c7d4a16309c68bf27e7e8664b6a1f0d5d5ef9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
discard """
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