Posted to tcl by aspect at Sat Jan 12 05:40:03 GMT 2013view raw

  1. proc nestedForeach {args} {
  2. set body [lindex $args end]
  3. set args [lreplace $args end end]
  4. foreach {values key} [lreverse $args] {
  5. set body [list foreach $key $values $body]
  6. }
  7. uplevel 1 $body
  8. }
  9.