I'm creating a function that multiplies to polynomials together. Part of this involves determining whether I'm multiplying two of the same variables (5x * 3x) or two different variables (5x * 3y).
The function takes two parameters (p1 and p2) which are the polynomials to be multiplied. And they are entered in the form:
'(5 (x 2)) '(3 (y 3))
= 5x^2 * 3y^3.
(These could be anything though..)
So i have an if statement to determine whether the variables are the same:
(if (EQUAL (car(car (cdr p1))) (car(car (cdr p2)))).
Where (car(car (cdr p1)) and (car(car (cdr p2)) are the x and y.
I now want to add these two variable into a list so that the list looks like (x y).
Here is what I've tried:
(setq pList (append (car(car ( cdr p1 )))))
(setq pList (append (car(car ( cdr p2 )))))
But what seems to happen is the first line of code add's the X into the list, but the second line of code replaces the x with a y, so I'm just left with (y). I've tried all sorts of things but nothing that seems to work!
Any help would be much appreciated!