Runtime evaluation/In an environment: Difference between revisions

Content added Content deleted
(Added Oz solution.)
Line 163:
 
<lang javascript>evalWithX('Math.exp(x)', 0, 1) // returns 1.718281828459045</lang>
 
 
=={{header|Lua}}==
<lang lua>
code = loadstring"return x^2" --this doesn't really need to be input, does it?
val1 = setfenv(code, {x = io.read() + 0})()
val2 = setfenv(code, {x = io.read() + 0})()
print(val2 - val1)
</lang>
 
=={{header|Metafont}}==