diff options
author | takaomag <takaomag@users.noreply.github.com> | 2015-07-02 14:32:13 +0000 |
---|---|---|
committer | takaomag <takaomag@users.noreply.github.com> | 2015-07-02 14:32:13 +0000 |
commit | f529e14b0443708292a506b3dcc01d0bdb093013 (patch) | |
tree | 1061adb02ef28b09289ee91fc2a74513baf42faa | |
parent | cf63f90d0ff8586dfba218d2dd80bdb84bf69627 (diff) | |
download | Nim-f529e14b0443708292a506b3dcc01d0bdb093013.tar.gz |
Fix algorithm.reversed to accept non-zero 'first' arg
-rw-r--r-- | lib/pure/algorithm.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index e087b5ac9..899420fca 100644 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -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] = |