3 (define (div-terms L1 L2)
4 (if (empty-termlist? L1)
5 (list (the-empty-termlist) (the-empty-termlist))
6 (let ((t1 (first-term L1))
8 (if (> (order t2) (order t1))
9 (list (the-empty-termlist) L1)
10 (let ((new-c (div (coeff t1) (coeff t2)))
11 (new-o (- (order t1) (order t2))))
13 (div-terms (sub-terms L1
14 (mul-term-by-all-terms (make-term new-o new-c)
17 (list (adjoin-term (make-term new-o new-c)
19 (cadr rest-of-result))))))))
21 (define (div-poly P1 P2)
22 (if (same-variable? (variable P1)
24 (let ((t1 (term-list P1))
26 (let ((div-results (div-terms t1 t2)))
27 (list (make-poly (variable P1) (car div-results))
28 (make-poly (variable P1) (cadr div-results)))))
29 (error "Polynomials are not of the same variable -- DIV-POLY")))