Nono713
Gold Member
MHB
- 615
- 4
JaAnTr said:Ok, that makes sense and I've changed it now to represent the new way. I'm having a bit of an issue with some Lisp syntax for the base case. I know the logic behind what I want to do. I think the best way is to say when the remainder, the variable that holds everything after the first two polynomials is empty, return the polynomial.
In code:
Code:(if(eq nil remainder) (p1))
I get a warning saying that P1 is an undefined function. This is probably a stupid question but I just can't seem to get it working.
Actually that's not quite right (your logic). If the remainder is nil, there could still be 2 elements in the list, so they should still be collected. What you need to check for is when there are less than 2 elements, and that happens if (and only if) the second element is nil. So this is the element you should check against for the base case. (you're getting there!)
As for your second question, I used the "null" function to check for nil:
Code:
(if (null yourvar)
; ...
)