This is the main module of the pykot library. It started as a port of some Python / Kotlin features.
GitHub link: https://github.com/jabbalaci/nimpykot
Author: Laszlo Szathmary (Jabba Laci), 2018, 2025
Iterators
iterator pyRange(a, b: int; step: Positive = 1): int {....raises: [], tags: [], forbids: [].}
-
An iterator that goes from a (incl.) until b (excl.). step is optional and must be >= 1.
Mimics Python's range(). system.range exists, so it had to be renamed. Negative step is not supported. Use countdown in that case.
Example:
var res = newSeq[int]() for i in pyRange(5, 8): res.add(i) doAssert res == @[5, 6, 7]
iterator pyRange(b: int): int {....raises: [], tags: [], forbids: [].}
-
An iterator that goes from 0 (incl.) until b (excl.).
Mimics Python's range(). system.range exists, so it had to be renamed.
Example:
var res = newSeq[int]() for i in pyRange(5): res.add(i) doAssert res == @[0, 1, 2, 3, 4]
iterator until(a, b: int): int {....raises: [], tags: [], forbids: [].}
-
An iterator that goes from a (incl.) until b (excl.).
I first saw this construction in Kotlin.
Example:
var res = newSeq[int]() for _ in 1.until(5): res.add(0) doAssert res == @[0, 0, 0, 0]