Horner's rule for polynomial evaluation: Difference between revisions

m
Line 442:
=={{header|Elena}}==
{{trans|C#}}
ELENA 3.4.x :
<lang elena>import extensions.;
import system'routines.;
horner(coefficients,variable)
{
[
^ coefficients .clone; ().sequenceReverse; ().accumulate(Real new) withReal(:accumulator:coefficient),(accumulator,coefficient => accumulator * variable + coefficient))
}
]
public program()
{
[
console .printLine(horner((new real[]{-19.0r, 7.0r, -4.0r, 6.0r)}, 3.0r))
]}</lang>
{{out}}
<pre>
Anonymous user