Fix to included last element in reversed

This commit is contained in:
def 2014-07-09 18:54:05 +02:00
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] = proc reversed*[T](a: openArray[T], first, last: int): seq[T] =
## returns the reverse of the array `a[first..last]`. ## returns the reverse of the array `a[first..last]`.
result = newSeq[T](last - first) result = newSeq[T](last - first + 1)
var x = first var x = first
var y = last var y = last
while x < last: while x <= last:
result[x] = a[y] result[x] = a[y]
dec(y) dec(y)
inc(x) inc(x)