product more robust against empty input

This commit is contained in:
Simon Hafner 2014-01-30 23:55:43 -06:00
commit e01fb17d02
2 changed files with 6 additions and 0 deletions

View file

@ -148,6 +148,7 @@ proc product*[T](x: openarray[seq[T]]): seq[seq[T]] =
var next: seq[T] = @[]
next.setLen(x.len)
for i in 0..(x.len-1):
if len(x[i]) == 0: return
initial[i] = len(x[i])-1
indexes = initial
while true: