Skip to content

Commit

Permalink
Merge pull request #1488 from kmsquire/iterator_update
Browse files Browse the repository at this point in the history
Make product iterator iterate in a more natural fashion.
  • Loading branch information
JeffBezanson committed Nov 3, 2012
2 parents ccf7f27 + d3b271c commit 8d7686f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extras/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function start(it::Product)
end
end
vs = Array(Any, n)
for i = 1:n
for i = n:-1:1
vs[i], js[i] = next(it.xss[i], js[i])
end
return js, vs
Expand All @@ -201,11 +201,11 @@ function next(it::Product, state)
ans = tuple(vs...)

n = length(it.xss)
for i in 1:n
for i in n:-1:1
if !done(it.xss[i], js[i])
vs[i], js[i] = next(it.xss[i], js[i])
break
elseif i == n
elseif i == 1
vs = nothing
break
end
Expand Down

0 comments on commit 8d7686f

Please sign in to comment.