On my answer http://codegolf.stackexchange.com/a/107557/29325https://codegolf.stackexchange.com/a/107557/29325 I can demonstrate:
Usually
set j 0;while \$j<$n;{...;incr j}
is shorter than the equivalentfor {set j 0} {$j<$n} {incr j} {...}
When the looping variable begins at 1, we can do the increment as part of the
while
test condition, avoiding to write beforeset i 1
unnecessarily:while {[incr i]<=$n} {...}
instead ofset i 1;while \$i<=$n;{...;incr i}
ATTENTION: One can only do 2. in the case of an outer loop! I could not apply it to my j
variable as it needs to be reset to 1 in the outside of its own inner loop! And incr j
would acquire the value that was set on the last step of the inner loop, instead of grabbing an undefined variable j
to assume 0
and increment it to 1
!