foreach(3tcl) Tcl Built-In Commands foreach(3tcl) ______________________________________________________________________________ NAME foreach - SYNOPSIS foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body ______________________________________________________________________________ DESCRIPTION foreach varname list varname body Tcl list ()foreach varname lindex Tcl body (list1 list2)(varlist1 varlist2) varlist list list break continue body for Foreach EXAMPLES i j set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. i j set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO for(n), while(n), break(n), continue(n) KEYWORDS foreach, iteration, list, looping [] [] 2001/08/05 Linux man : http://cmpp.linuxforum.net man man https://github.com/man-pages-zh/manpages- zh Tcl foreach(3tcl)