乐正

Actions speak louder than words.

Sicp-ex2-89

问题

请定义一些过程,实现上面讨论的稠密多项式的项表表示。

解答

1
2
3
4
5
6
7
8
9
10
11
12
(define (display-polynomial p)
  (define (internal L current-order)
    (cond ((< current-order 0) '())
          ((empty-termlist? p)
           (cons 0 (internal L (- current-order 1))))
          (else
            (let ((t (first-term L)))
              (if (= (order t) current-order)
                  (cons (coeff t) (internal (rest-terms L) (- current-order 1)))
                  (cons 0 (internal L (- current-order 1))))))))

  (internal p (order (first-term p)))

draft

« sicp-ex2-88 sicp-ex2-90 »

Comments