Horner's rule for polynomial evaluation
Last updated
Was this helpful?
Last updated
Was this helpful?
A recursive version would spare us the need for reversing the list of coefficients. However, special care must be taken in order to write it, because the way Raku implements lists is not optimized for this kind of treatment. -style lists are, and fortunately it is possible to emulate them with and the reduction meta-operator:
We can also use the composition operator:
One advantage of using the composition operator is that it allows for the use of an infinite list of coefficients.