#!/software/tcl/bin/tclsh proc power {base p} { set result 1 while {$p > 0} { set result [expr $result * $base] set p [expr $p - 1] } return $result }
Now provide a textual user interface to power ...
set cont "y" while {$cont == "y" || $cont == "Y"} { puts "Enter base: " gets stdin base puts "Enter power: " gets stdin p puts "$base ^ $p = [power $base $p]" puts "Continue? (yn): " gets stdin cont } exit