Arithmetic evaluation: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: flat before reduction) |
m (→{{header|Sidef}}: minor code simplification) |
||
Line 4,716:
Testing the function:
<lang ruby>for expr,res in [
['2+3' => 5],
['-4-3' => -7],
Line 4,724:
['2*-3--4+-0.25' => -2.25],
['2 * (3 + (4 * 5 + (6 * 7) * 8) - 9) * 10' => 7000],
]
var num = evalArithmeticExp(expr);
assert_eq(num
▲ "%-45s == %10g\n".printf(expr, num);
}</lang>
|