Created
December 8, 2018 08:03
-
-
Save technicallyagd/3385f63ae7df889184457d46164f16cf to your computer and use it in GitHub Desktop.
proc that returns iterator
This file contains 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
let | |
ages = @[20, 25, 18, 32] | |
proc reader(lst: seq[int]): iterator(): int = | |
result = iterator (): int = | |
for n in lst: | |
yield n | |
proc main() = | |
let read = reader(ages) # How to pass an argument? | |
echo read() | |
echo read() | |
# ############################################################################ | |
when isMainModule: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment