An example of a procedure with variable number of arguments is
proc avg {numbers} { set sum 0 foreach number $numbers { set sum [expr $sum + $number] } set average [expr $sum/[llength $numbers]] return $average } puts [avg {50 50 50 60}] puts [avg {50 50 50}]
Result:
52 50
Recent Comments