Runtime evaluation/In an environment: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: re-wrote code to not use a global variable.) |
m (added whitespace.) |
||
Line 1: | Line 1: | ||
{{task}} Given a program in the language (as a string or AST) with a free variable named <var>x</var> (or another name if that is not valid syntax), evaluate it with <var>x</var> bound to a provided value, then evaluate it again with <var>x</var> bound to another provided value, then subtract the result of the first from the second and return or print it. |
{{task}} Given a program in the language (as a string or AST) with a free variable named <var>x</var> (or another name if that is not valid syntax), evaluate it with <var>x</var> bound to a provided value, then evaluate it again with <var>x</var> bound to another provided value, then subtract the result of the first from the second and return or print it. |
||
Do so in a way which: |
Do so in a way which: |
||
Line 5: | Line 6: | ||
* is plausibly extensible to a runtime-chosen set of bindings rather than just <var>x</var> |
* is plausibly extensible to a runtime-chosen set of bindings rather than just <var>x</var> |
||
* does not make <var>x</var> a ''global'' variable |
* does not make <var>x</var> a ''global'' variable |
||
or note that these are impossible. |
or note that these are impossible. |
||
===See also=== |
===See also=== |
||
* For more general examples and language-specific details, see [[Eval]]. |
* For more general examples and language-specific details, see [[Eval]]. |
||
* [[Dynamic variable names]] is a similar task. |
* [[Dynamic variable names]] is a similar task. |
||
<br><br> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |