Skip to content

Instantly share code, notes, and snippets.

@technicallyagd
Created December 8, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technicallyagd/3385f63ae7df889184457d46164f16cf to your computer and use it in GitHub Desktop.
Save technicallyagd/3385f63ae7df889184457d46164f16cf to your computer and use it in GitHub Desktop.
proc that returns iterator
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