Merge pull request #2733 from apense/patch-4

Small sequence fix for algorithm.nim
This commit is contained in:
Andreas Rumpf 2015-05-25 00:49:48 +02:00
commit 39c00d3dd1

View file

@ -243,7 +243,7 @@ template sortedByIt*(seq1, op: expr): expr =
proc product*[T](x: openArray[seq[T]]): seq[seq[T]] = proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
## produces the Cartesian product of the array. Warning: complexity ## produces the Cartesian product of the array. Warning: complexity
## may explode. ## may explode.
result = @[] result = newSeq[seq[T]]()
if x.len == 0: if x.len == 0:
return return
if x.len == 1: if x.len == 1:
@ -253,8 +253,7 @@ proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
indexes = newSeq[int](x.len) indexes = newSeq[int](x.len)
initial = newSeq[int](x.len) initial = newSeq[int](x.len)
index = 0 index = 0
# replace with newSeq as soon as #853 is fixed var next = newSeq[T]()
var next: seq[T] = @[]
next.setLen(x.len) next.setLen(x.len)
for i in 0..(x.len-1): for i in 0..(x.len-1):
if len(x[i]) == 0: return if len(x[i]) == 0: return