Fixed algorithm.reversed to work for empty seq's.
This commit is contained in:
parent
134c44f3be
commit
4e222a1506
1 changed files with 2 additions and 1 deletions
|
|
@ -48,8 +48,9 @@ proc reverse*[T](a: var openArray[T]) =
|
|||
## reverses the array `a`.
|
||||
reverse(a, 0, a.high)
|
||||
|
||||
proc reversed*[T](a: openArray[T], first, last: Natural): seq[T] =
|
||||
proc reversed*[T](a: openArray[T], first: Natural, last: int): seq[T] =
|
||||
## returns the reverse of the array `a[first..last]`.
|
||||
assert last >= first-1
|
||||
var i = last - first
|
||||
var x = first.int
|
||||
result = newSeq[T](i + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue