Jump to content

Runtime evaluation/In an environment: Difference between revisions

Scala solution added
(Scala solution added)
Line 880:
<code>eval</code> can then use the local variable <code>x</code> in this context.
 
=={{header|Scala}}==
<lang Scala>object Eval extends App {
 
def evalWithX(expr: String, a: Double, b: Double)=
{val x = b; eval(expr)} - {val x = a; eval(expr)}
 
println(evalWithX("Math.exp(x)", 0.0, 1.0))
 
}</lang>
=={{header|Scheme}}==
Almost identical to the [[Common Lisp]] version above.
Line 886 ⟶ 895:
(at-b (eval `(let ((x ',b)) ,prog))))
(- at-b at-a)))</lang>
 
 
=={{header|Sidef}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.