Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 10:42, 23 September 2011
, 12 years ago→{{header|Perl}}: might as well use the convenience of prototype; not popping a ref is generally more practical
(→{{header|Perl}}: might as well use the convenience of prototype; not popping a ref is generally more practical) |
|||
Line 645:
=={{header|Perl}}==
<lang Perl>use
use strict;
use warnings;
sub horner(
my ($
my $result = 0;
▲ $result = $result * $x + pop @$coeff_ref;
▲ }
return $result;
}
my @coeff = (-19.0, 7, -4, 6);
my $x = 3;
say horner
===Functional version===
|