Posted to tcl by aspect at Thu May 11 10:52:11 GMT 2017view raw
- # nested foreach.
- proc foreach* {args} {
- set script [lindex $args end]
- set args [lrange $args 0 end-1]
- foreach {b a} [lreverse $args] {
- set script [list foreach $a $b $script]
- }
- tailcall {*}$script
- }
- foreach* {*}{
- compartment {5compt}
- generator {one two three}
- switchboard {on two three}
- } {
- puts [list compartment $compartment generator $generator switchboard $switchboard]
- }