Anonymous user
Arithmetic evaluation: Difference between revisions
m
→{{header|Tcl}}: {{out}}
m (→{{header|Sidef}}: fixed the translation note) |
m (→{{header|Tcl}}: {{out}}) |
||
Line 4,393:
=={{header|Tcl}}==
{{works with|Tcl|8.5}}
The code below delivers the AST for an expression
in a form that it can be immediately eval-led,
using Tcl's prefix operators.
<lang Tcl>namespace import tcl::mathop::*
Line 4,438 ⟶ 4,440:
puts "$test ..... [eval $test] ..... [eval [eval $test]]"
}</lang>
{{out}}
ast 2-2 ..... - 2 2 ..... 0
ast 1-2-3 ..... - [- 1 2] 3 ..... -4
|