Posted to tcl by emiliano at Thu Jun 08 23:35:04 GMT 2023view raw
- package require Tcl 8.6 ; # uses [lmap]
- # or [setx], bring your paint
- proc let {varname expr} {
- upvar 1 $varname var
- set var [uplevel 1 [list expr $expr]]
- }
- # or [exprm]
- proc lexpr {args} {
- lmap expr $args {
- uplevel 1 [list expr $expr]
- }
- }
- % let a {acos(-1)}
- 3.141592653589793
- % let b {sqrt(5)}
- 2.23606797749979
- % let c {$a + $b}
- 5.377660631089583
- % lexpr {$a -1} {$b**2} {$c * $a}
- 2.141592653589793 5.000000000000001 16.894419132130086