This commit is contained in:
Andreas Rumpf 2020-04-19 10:01:04 +02:00 • committed by GitHub
commit 9874981e75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View file

@ -24,7 +24,7 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} =
yield res
if res == b: break
dec(res, step)
elif T is IntLikeForCount:
elif T is IntLikeForCount and T is Ordinal:
var res = int(a)
while res >= int(b):
yield T(res)
@ -52,7 +52,7 @@ when defined(nimNewRoof):
## for i in countup(2, 9, 3):
## echo i # => 2; 5; 8
mixin inc
when T is IntLikeForCount:
when T is IntLikeForCount and T is Ordinal:
var res = int(a)
while res <= int(b):
yield T(res)
@ -73,7 +73,7 @@ when defined(nimNewRoof):
## for i in 3 .. 7:
## echo i # => 3; 4; 5; 6; 7
mixin inc
when T is IntLikeForCount:
when T is IntLikeForCount and T is Ordinal:
var res = int(a)
while res <= int(b):
yield T(res)
@ -138,7 +138,7 @@ else: # not defined(nimNewRoof)
##
## for i in countup(2, 9, 3):
## echo i # => 2; 5; 8
when T is IntLikeForCount:
when T is IntLikeForCount and T is Ordinal:
var res = int(a)
while res <= int(b):
yield T(res)
@ -159,7 +159,7 @@ else: # not defined(nimNewRoof)
## for i in 3 .. 7:
## echo i # => 3; 4; 5; 6; 7
mixin inc
when T is IntLikeForCount:
when T is IntLikeForCount and T is Ordinal:
var res = int(a)
while res <= int(b):
yield T(res)