for
loop expressions w/ constant
When adding a class constant to a loop expression, it affects the constant that must be added in the expression.
Suppose we have the two loop expressions below for figure sizes of 5 and 9. The third line of the table shows the general formula that would be used if we turned our figure's size into a constant named SIZE
.
size | expression | relationship |
---|---|---|
5 |
8 * line + 16 |
16 = 3 * 5 + 1 |
9 |
8 * line + 28 |
28 = 3 * 9 + 1 |
SIZE |
8 * line + (3 * SIZE + 1) |
continued on the next slide ...