Problem 57715. Easy Sequences 96: One-line Code Challenge - Polynomial Folding Function
The Matlab fold function is a very useful functional programming construct. Unfortunatlely, fold is not available io Cody players.
In this problem we are required to create the function foldPoly, that takes in 2 inputs, a polynomial vector P and a values vector V. Assuming V is never empty, we define the function as follows:
which is equivalent, in older Matlab, to:
The challenge here is to write the foldPoly function in just one (1) line of code, excluding the function start and end line.
NOTE: Empty lines and comment lines (starting with %) shall not be counted, but semicolons (;) will be considered as an end-of-line character.
HINT: It is helpful to have a Matlab in your computer (or you can use Matlab Online), to be able check if your implementation behaves the same way as the built-in fold function.
Solution CommentsShow comments
Problem Recent Solvers2