Jump to content

Runtime evaluation/In an environment: Difference between revisions

→‎{{header|Tcl}}: (before: bad understanding of the tcl code? note the apply) maybe the error was elsewhere; now hopefully fixed
(→‎{{header|Octave}}: changed into an imitation of python, more or less)
(→‎{{header|Tcl}}: (before: bad understanding of the tcl code? note the apply) maybe the error was elsewhere; now hopefully fixed)
Line 179:
 
=={{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
 
proc eval_twiceevalit {func a b} {
set 1str [apply $func $a]
set 2nd [apply $funcexpr {$b]r}
expr {$2nd - $1st}
}
 
eval_twiceset a [evalit {x {expr {2 ** $x}}} 3 5 ];# ==> 24</lang>
set b [evalit {x {expr {2 ** $x}}} 5];
puts [expr {$2ndb - $1sta}];
</lang>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.