mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-08 12:54:22 +00:00
Fix to included last element in reversed
This commit is contained in:
@@ -36,10 +36,10 @@ proc reverse*[T](a: var openArray[T]) =
|
||||
|
||||
proc reversed*[T](a: openArray[T], first, last: int): seq[T] =
|
||||
## returns the reverse of the array `a[first..last]`.
|
||||
result = newSeq[T](last - first)
|
||||
result = newSeq[T](last - first + 1)
|
||||
var x = first
|
||||
var y = last
|
||||
while x < last:
|
||||
while x <= last:
|
||||
result[x] = a[y]
|
||||
dec(y)
|
||||
inc(x)
|
||||
|
||||
Reference in New Issue
Block a user