Fix algorithm.reversed to accept non-zero 'first' arg

This commit is contained in:
takaomag 2015-07-02 14:32:13 +00:00
commit f529e14b04

View file

@ -50,12 +50,12 @@ proc reverse*[T](a: var openArray[T]) =
proc reversed*[T](a: openArray[T], first, last: Natural): seq[T] = proc reversed*[T](a: openArray[T], first, last: Natural): 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 + 1) var i = last - first
var x = first.int var x = first.int
var y = last.int result = newSeq[T](i + 1)
while x <= last: while i >= 0:
result[x] = a[y] result[i] = a[x]
dec(y) dec(i)
inc(x) inc(x)
proc reversed*[T](a: openArray[T]): seq[T] = proc reversed*[T](a: openArray[T]): seq[T] =