I'm an F# beginner trying to create a function mul to multiply two polynomials. I'm using three helper functions: add, mulX and mulC which respectively add polynomials, multiply by x and multiply by constant. The idea is that I'm representing my polynomials in lists, so [1;2;3] would be 1+2x+3x^2.
I've gotten the following definition as a guideline for combining the helper functions.
However, I can't seem to get it to work, even though (I think) I've followed the guideline completely.
I've added a screenshot of the code, helper functions and output here. I get 2+7x+13x^2+11x^3+3x^4, and I'm supposed to get 2+7x+12x^2+10x^3+2x^4+3*x^5.
I'm sorry if the format is bad, this is my first post.
Where did I go wrong? I've tested my helper functions, and they seem to work. Any help is appreciated!