RosettaCodeData/Task/Extend-your-language/Tcl/extend-your-language-3.tcl
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

8 lines
359 B
Tcl

proc if2 {cond1 cond2 body00 body01 body10 body11} {
# Must evaluate both conditions, and should do so in order
# Extra negations ensure boolean interpretation
set c1 [expr {![uplevel 1 [list expr $cond1]]}]
set c2 [expr {![uplevel 1 [list expr $cond2]]}]
# Use those values to pick the script to evaluate
uplevel 1 [set body$c1$c2]
}