Fixed silly continue
The old if/else was weird and unnecessary
This commit is contained in:
parent
ea1809a931
commit
3491047141
1 changed files with 2 additions and 5 deletions
|
|
@ -240,14 +240,11 @@ template sortedByIt*(seq1, op: expr): expr =
|
||||||
proc isSorted*[T](a: openarray[T],
|
proc isSorted*[T](a: openarray[T],
|
||||||
cmp: proc(x, y: T): int {.closure.},
|
cmp: proc(x, y: T): int {.closure.},
|
||||||
order = SortOrder.Ascending): bool =
|
order = SortOrder.Ascending): bool =
|
||||||
## Tests whether `a` is sorted
|
if len(a) <= 1: return true
|
||||||
if len(a) <= 1: return true # empty or one-element lists are already sorted
|
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
for i in 0..<len(a)-1:
|
for i in 0..<len(a)-1:
|
||||||
if cmp(a[i],a[i+1]) * order <= 0: # same test as `sort`
|
if cmp(a[i],a[i+1]) * order > 0:
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
|
proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue