Re: TclX loop slow in the default case



On Aug 26, 11:02 pm, Evil Son <ewilsonm...@xxxxxxxxx> wrote:

proc loop_explicit {lim} {
loop i 0 1 $lim {}

Afraid you swapped two arguments here:

loop var start end ?increment? command

so you're iterating from 0 to 1 with a $lim increment, explaining the
constant and extremely short time for loop_explicit:

7 9 0.02 loop_explicit
7 9 0.02 loop_explicit
7 10 0.03 loop_explicit

In general, an O(N) algorithm suddenly switching to O(1) in constant
space is suspect ;-) Another, slightly more interesting case would be
a one-page proof that P=NP...

-Alex
.