titer_no_tuple_unpack.nim 331 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. output: '''
  3. 3 4
  4. 4 5
  5. 5 6
  6. 6 7
  7. 7 8
  8. (x: 3, y: 4)
  9. (x: 4, y: 5)
  10. (x: 5, y: 6)
  11. (x: 6, y: 7)
  12. (x: 7, y: 8)
  13. '''
  14. """
  15. iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] =
  16. var a = fromm
  17. while a <= to:
  18. yield (a, a+1)
  19. inc(a, step)
  20. for a, b in xrange(3, 7):
  21. echo a, " ", b
  22. for tup in xrange(3, 7):
  23. echo tup