Fix to included last element in reversed

This commit is contained in:
def
2014-07-09 18:54:05 +02:00
parent c591db16c8
commit 8b796763a3

View File

@@ -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)