Arithmetic evaluation: Difference between revisions

Content added Content deleted
Line 1,448: Line 1,448:


=={{header|Tcl}}==
=={{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.
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>
<lang Tcl>namespace import tcl::mathop::*
namespace import tcl::mathop::*


proc arieval str {
proc arieval str {
Line 1,494: Line 1,494:
} \n] {
} \n] {
puts "$test ..... [eval $test] ..... [eval [eval $test]]"
puts "$test ..... [eval $test] ..... [eval [eval $test]]"
}</lang>
}
</lang>
Output:<pre>
Output:<pre>
arieval 2-2 ..... - 2 2 ..... 0
arieval 2-2 ..... - 2 2 ..... 0