solution to 2.87
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 23 Dec 2010 13:55:31 +0000 (19:25 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Fri, 31 Dec 2010 08:09:38 +0000 (13:39 +0530)
src/sicp/ex2_87.rkt [new file with mode: 0644]

diff --git a/src/sicp/ex2_87.rkt b/src/sicp/ex2_87.rkt
new file mode 100644 (file)
index 0000000..5f503f5
--- /dev/null
@@ -0,0 +1,16 @@
+#lang racket
+
+(put '=zero? '(polynomial)
+     (lambda (p)
+       (define (terms-=zero? terms)
+         (if (empty-termlist? terms)
+             #t
+             (let ((term (first-term terms)))
+               (let ((c (coeff term)))
+                 (let ((type (type-tag c)))
+                   (let ((zproc (get '=zero? (list type))))
+                     (if (zproc c)
+                         (terms-=zero? (rest-terms terms))
+                         #f)))))))
+       
+       (terms-=zero? (term-list p))))
\ No newline at end of file