3 (define (negate x) (- x))
5 (put 'negate '(scheme-number)
6 (lambda (r) (tag (negate r))))
8 (put 'negate '(rational)
9 (lambda (r) (tag (negate r))))
12 (lambda (r) (tag (negate r))))
14 (put 'negate '(complex)
15 (lambda (c) (tag ((get 'make 'complex) (negate (real c))
18 (put 'negate '(polynomial)
19 (lambda (p) (tag (negate-poly p))))
21 (define (negate-terms terms)
22 (if (empty-termlist? terms)
24 (let ((t1 (first-term terms)))
27 (adjoin-term (make-term o (negate c))
28 (negate-terms (rest-terms terms)))))))
30 (define (negate-poly p)
31 (let ((terms (term-list p)))
32 (make-poly (variable p) (negate-terms terms))))
34 (put 'negate '(polynomial)
35 (lambda (p) (tag (negate-poly p))))
37 (define (negate p) (apply-generic 'negate p))
39 (define (sub-poly p1 p2)
40 (add-poly p1 (negate p2)))
42 (put 'sub '(polynomial polynomial)
43 (lambda (p1 p2) (tag (sub-poly p1 p2))))