Runtime evaluation/In an environment: Difference between revisions

Content added Content deleted
(→‎{{header|Tcl}}: this imitates other examples (right?))
m (→‎{{header|Octave}}: modified to resemble to other examples)
Line 95: Line 95:
=={{header|Octave}}==
=={{header|Octave}}==


<lang octave>function r = calcit(f, val)
<lang octave>function r = calcit(f, val1, val2)
x = val;
x = val1;
r = eval(f);
a = eval(f);
x = val2;
b = eval(f);
r = b-a;
endfunction
endfunction


p = "x .* 2";
p = "x .* 2";
a = calcit(p, [1:3]);
disp(calcit(p, [1:3], [4:6]));</lang>
b = calcit(p, [4:6]);

disp(b-a);</lang>


Output:
Output: