Created
December 31, 2014 16:52
-
-
Save def-/177290281185d8dd9358 to your computer and use it in GitHub Desktop.
Iterators with shallowCopy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TaskFn = iterator (): float | |
iterator a1(): float {.closure.} = | |
var k = 10 | |
while k > 0: | |
echo "a1 ", k | |
dec k | |
yield 1.0 | |
iterator a2(): float {.closure.} = | |
var k = 15 | |
while k > 0: | |
echo "a2 ", k | |
dec k | |
yield 2.0 | |
var | |
x = a1 | |
y = a2 | |
z: TaskFn | |
discard x() | |
shallowCopy(z, x) | |
shallowCopy(z, y) | |
discard x() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment