Fix algorithm.reversed to accept non-zero 'first' arg
This commit is contained in:
parent
cf63f90d0f
commit
f529e14b04
1 changed files with 5 additions and 5 deletions
|
|
@ -50,12 +50,12 @@ proc reverse*[T](a: var openArray[T]) =
|
|||
|
||||
proc reversed*[T](a: openArray[T], first, last: Natural): seq[T] =
|
||||
## returns the reverse of the array `a[first..last]`.
|
||||
result = newSeq[T](last - first + 1)
|
||||
var i = last - first
|
||||
var x = first.int
|
||||
var y = last.int
|
||||
while x <= last:
|
||||
result[x] = a[y]
|
||||
dec(y)
|
||||
result = newSeq[T](i + 1)
|
||||
while i >= 0:
|
||||
result[i] = a[x]
|
||||
dec(i)
|
||||
inc(x)
|
||||
|
||||
proc reversed*[T](a: openArray[T]): seq[T] =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue