out [ args x y z ] out [ args 1 [+ 1 1] [+ 1 1 1] ] proc sum {x y} { + [get x] [get y] } + 22 [ sum 333 [+ [one] [one]][zero][zero] ] + 22 [ sum 333 [+ [one] [one]][zero][ zero ] ] if one one null if zero null one set x -5 while { get x } { out =======[get x]======= set x [ + [get x] 1 ] } must "a b c" { ident {a b c} } must {a b1 c} { ident "a b[one] c" } must "1 11 1" {ident "[one] [one][one] [one]" } proc tri x { append ::tri ($x) if {get x} then { + [get x] [tri [- [get x] 1]] } else { return [get x] } } proc factorial x { lappend ::fac ($x) if {>= [get x] 2} { * [get x] [factorial [+ -1 [get x]]] } { * } } must 120 {factorial 5} must 55 {tri 10} must (10)(9)(8)(7)(6)(5)(4)(3)(2)(1)(0) {get tri} must "(5) (4) (3) (2) (1)" {get fac} foreach i {one two three} { out i=[get i] } foreach i [list one two three] { out i=[get i] } must [list 10 20 30] {foreach a {1 2 3} {* 10 $a}} must [list 0 1 2 3 ] {range 4} foreach x {1 2 3 4 5 6 7 8 9 10} { if {== $x 5} break incr abc $x } must 10 {get abc} foreach x {1 2 3 4 5 6 7 8 9 10} { if {== $x 5} continue incr def $x } must 50 {get def} ident verbose set ht(3) 1 set ht(blind) 100 set ht(mice) 10000 must [list 3 blind mice] {names ht} must 3 {lindex [names ht] 0} must blind {lindex [names ht] 1} must mice {lindex [names ht] 2} must {} {lindex [names ht] 3} must "101 120 112 108 111 100 101" {explode explode} must explode {implode [explode explode]} proc foo x { if {> $x 0} { foo [incr x -1] } { error "you have zero foo" } } foo 4