Runtime evaluation/In an environment: Difference between revisions
Runtime evaluation/In an environment (view source)
Revision as of 18:32, 21 April 2024
, 25 days agoAdded FreeBASIC
(Added FreeBASIC) |
|||
(7 intermediate revisions by 5 users not shown) | |||
Line 56:
</syntaxhighlight>
The result is 24.0 (a real number).
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">code: [x * 2]
fn: function [x]->
do with 'x code
a: fn 2
b: fn 4
print b - a</syntaxhighlight>
{{out}}
<pre>4</pre>
=={{header|AutoHotkey}}==
Line 210 ⟶ 224:
=={{header|Elena}}==
ELENA
Using VM console client:
Line 221 ⟶ 235:
var arg := program_arguments[2];
var program := lscript.
console.printLine(
text,",",arg," = ",program.eval(arg.toReal()));
Line 314 ⟶ 328:
LOOP
; ok</syntaxhighlight>
=={{header|FreeBASIC}}==
<syntaxhighlight lang="vbnet">#include "solver.bi"
Dim As String expression = "(x ^ 2 )-7"
setVar("x",1.2)
Print "one = ";Solver(expression)
setVar("x",3.4)
Print "two = ";Solver(expression)
Sleep</syntaxhighlight>
{{out}}
<pre>one = -5.560000000000001
two = 4.559999999999999</pre>
=={{header|Genyris}}==
Line 992 ⟶ 1,021:
=={{header|RPL}}==
A first way to answer the task is to use the possibility of passing local variables from one program to another, the calling program being in charge of achieving the binding of values to the x variable.
≪ 2 x ^ ≫ 'POWR2' STO
{{in}}
<pre>
5 3 DIFFP
▲3 5 ≪ → x ≪ POW2 SWAP ≫ → x ≪ POW2 - ≫ EVAL
</pre>
{{out}}
Line 1,001 ⟶ 1,033:
1: 24
</pre>
Another solution is to let the algebraic interpreter do the binding:
≪ → x ≪ 2 x ^ ≫ ≫ 'POWR2' STO
{{in}}
<pre>
'POWR2(5)-POWR2(3)' EVAL
</pre>
{{out}}
<pre>
1: 24
</pre>
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">def bind_x_to_value(x)
Line 1,473 ⟶ 1,516:
=={{header|Wren}}==
Wren has
However, it only appears to work with module level variables.
<syntaxhighlight lang="
var x
Line 1,520 ⟶ 1,563:
{{omit from|GUISS|Does not have variables}}
{{omit from|Lily}}
{{omit from|Insitux}}
|