fixes #4220
This commit is contained in:
parent
5c5e54d3a9
commit
45437eb113
2 changed files with 28 additions and 2 deletions
|
|
@ -2005,7 +2005,13 @@ iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
|
|||
## step count. `T` may be any ordinal type, `step` may only
|
||||
## be positive. **Note**: This fails to count to ``low(int)`` if T = int for
|
||||
## efficiency reasons.
|
||||
when T is IntLikeForCount:
|
||||
when T is (uint|uint64):
|
||||
var res = a
|
||||
while res >= b:
|
||||
yield res
|
||||
if res == b: break
|
||||
dec(res, step)
|
||||
elif T is IntLikeForCount:
|
||||
var res = int(a)
|
||||
while res >= int(b):
|
||||
yield T(res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue