RosettaCodeData/Task/Extend-your-language/Tcl/extend-your-language-3.tcl
2023-07-01 13:44:08 -04: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]
}