]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_87.rkt
Solution to 4.33. This had been difficult to get right, though conceptually it was
[sicp.git] / src / sicp / ex2_87.rkt
1 #lang racket
2
3 (put '=zero? '(polynomial)
4      (lambda (p)
5        (define (terms-=zero? terms)
6          (if (empty-termlist? terms)
7              #t
8              (let ((term (first-term terms)))
9                (let ((c (coeff term)))
10                  (let ((type (type-tag c)))
11                    (let ((zproc (get '=zero? (list type))))
12                      (if (zproc c)
13                          (terms-=zero? (rest-terms terms))
14                          #f)))))))
15        
16        (terms-=zero? (term-list p))))