if 0 {[Richard Suchenwirth] 2003-08-08 - You can write an algorithm elegantly (e.g. in few lines of code, using few or no local variables, etc.), or performantly (i.e. not wasteful in time or memory). Ideally, these two come together, but in reality, elegant algorithms may show bad performance. Consider this elegant way of computing the sum of a list of numbers:} proc sum1 list {expr [join $list +]} if 0 {and the more conventional way, which uses 2 local variables:} proc sum2 list { set sum 0 foreach i $list { set sum [expr {$sum+$i}] } set sum } if 0 {Here is a little testframe to illustrate the respective performances, and draw them as curves on a canvas. It shows that sum1 (red) takes exponential time as lists grow longer, while sum2 (blue) remains pretty linear: [http://mini.net/files/elegance.jpg] } pack [canvas .c -bg white -width 600 -height 500] -expand 1 .c create line 0 500 0 500 -fill red -tag sum1 .c create line 0 500 0 500 -fill blue -tag sum2 for {set i 1} {$i<600} {incr i} { set list [lrange [string repeat "1 " [expr {$i*2}]] 0 end] set t1 [lindex [time {sum1 $list}] 0] .c coords sum1 [concat [.c coords sum1] $i [expr {500-$t1/40}]] set t2 [lindex [time {sum2 $list}] 0] .c coords sum2 [concat [.c coords sum2] $i [expr {500-$t2/40}]] update }