mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
21 lines
314 B
Nim
21 lines
314 B
Nim
discard """
|
|
output: '''5
|
|
14
|
|
0'''
|
|
"""
|
|
|
|
iterator count[T](x: T, skip: bool): int {.closure.} =
|
|
if skip: return x+10
|
|
else: yield x+1
|
|
|
|
if skip: return x+10
|
|
else: yield x+2
|
|
|
|
proc takeProc[T](x: iterator (x: T, skip: bool): int) =
|
|
echo x(4, false)
|
|
echo x(4, true)
|
|
echo x(4, false)
|
|
|
|
takeProc(count[int])
|
|
|