:
{count} = {index of current loop} + {size of current loop}*{count of parent loop}
:
x = 5
for i in range(x):
count = i
To be explicit, count = i + x*0but the second term does not matter, because there is no parent cycle. An example of two cycles can be more illuminated:
x = 5
y = 6
for i in range(x):
for j in range(y):
count = j + y*(i)
Note that I put iin parentheses to emphasize what it is {count of parent loop}. This formula can be easily extended to the third cycle:
x = 5
y = 6
z = 7
for i in range(x):
for j in range(y):
for k in range(z):
count = k + z*(j + y*(i))
etc.
Splic source
share