<< Previous exercise (2.86) | Index | Next exercise (2.88) >>


 ;; add into polynomial package 
 (define (zero-poly? poly) 
   (define (zero-terms? termlist) 
     (or (empty-termlist? termlist) 
         (and (=zero? (coeff (first-term termlist))) 
              (zero-terms? (rest-terms termlist))))) 
   (zero-terms? (term-list poly))) 

Don't need zero-terms? because the polynomial representation in the book cannot have a term-list with zero terms (see definition for adjoin-term)

 (define (zero-poly? p) 
    (empty-termlist? (term-list p))) 


The coefficient of a term can be either a number or a polynomial (Actually a number is a special polynomial with zero order). If it's number, we use the predicate (= x 0); If it's represented as a polynomial, it cannot be zero. The polynomial representation we adopt does not contain zero terms.

 ;;to be installed in polynomial package 
 (define (=zero? x) 
   (define (poly? x) 
     (pair? x)) 
   (cond ((number? x) (= x 0)) 
         ((poly? x) false) 
         (else (error "Unknown type")))) 
 (put '=zero? 'polynomial =zero?)