Horner's rule for polynomial evaluation
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. Lisp-style lists are, and fortunately it is possible to emulate them with Pairs and the reduction meta-operator:
We can also use the composition operator:
Output:
One advantage of using the composition operator is that it allows for the use of an infinite list of coefficients.
Output:
Last updated