Posted to tcl by mjanssen at Mon Jul 20 09:42:48 GMT 2020view raw
- proc run {program} {
- set pc 0
- while 1 {
- set cmd [lindex $program $pc]
- switch -exact $cmd {
- 0 {incr pc}
- 99 {break}
- }
- }
- }
- proc 0 {args} {
- return 1
- }
- proc 99 {args} {
- return -code break
- }
- proc run2 {program} {
- set pc 0
- while 1 {
- incr pc [{*}[lrange $program $pc end]]
- }
- }
- set program [lrepeat 10000 0] ; set a 2
- lappend program 99 ; set a 2
- time {run $program}
- time {run2 $program}