titer9.nim 314 B

123456789101112131415161718192021
  1. discard """
  2. output: '''5
  3. 14
  4. 0'''
  5. """
  6. iterator count[T](x: T, skip: bool): int {.closure.} =
  7. if skip: return x+10
  8. else: yield x+1
  9. if skip: return x+10
  10. else: yield x+2
  11. proc takeProc[T](x: iterator (x: T, skip: bool): int) =
  12. echo x(4, false)
  13. echo x(4, true)
  14. echo x(4, false)
  15. takeProc(count[int])