Jump to content

Horner's rule for polynomial evaluation: Difference between revisions

m
(add RPL)
Line 2,464:
Recursive:
<syntaxhighlight lang="ruby">func horner(coeff, x) {
(coeff.len > 0) \
&&? (coeff[0] + x*horner(coeff.ftlast(-1), x));
: 0
}
 
say horner([-19, 7, -4, 6], 3); # => 128</syntaxhighlight>
 
=={{header|Smalltalk}}==
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.