Runtime evaluation/In an environment: Difference between revisions
Content added Content deleted
(revert Tcl: insofar as I understand the Tcl, the old version was closer to correct, and I understand the change was an attempt to comply with my task req changes) |
(→{{header|Tcl}}: this imitates other examples (right?)) |
||
Line 175: | Line 175: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{incorrect|Tcl|The code provided should not itself be a function, but have x as a free variable.}} |
|||
<lang tcl>package require Tcl 8.5 |
<lang tcl>package require Tcl 8.5 |
||
proc eval_twice {func a b} { |
proc eval_twice {func a b} { |
||
set |
set x $a |
||
set |
set 1st [expr $func]; |
||
set x $b |
|||
set 2nd [expr $func]; |
|||
expr {$2nd - $1st} |
expr {$2nd - $1st} |
||
} |
} |
||
eval_twice |
puts [eval_twice {2 ** $x} 3 5];</lang> |