Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.87 关于多项式=zero?函数 #23

Open
dejavudwh opened this issue Feb 22, 2020 · 0 comments
Open

2.87 关于多项式=zero?函数 #23

dejavudwh opened this issue Feb 22, 2020 · 0 comments

Comments

@dejavudwh
Copy link

(define (install-polynomial-package) 
  ;; ... 
  (put '=zero? 'polynomial 
    (lambda(poly) 
      (or (empty-termlist? (term-list poly))
          (= 0 (first-term (coeff (term-list poly)))))))
  'done)

应该不能只判断最高项的系数,而且如果想获得更好的抽象能力的话使用=zero?代替= 0应该会更好,(coeff (term-list poly))应该也有错

下面是我自己写的

(define (install-polynomial-package) 
...
 (define (=zero? poly) 
   (define (zero-terms? termlist) 
     (if (empty-termlist? termlist)
         true 
         (and (=zero? (coeff (first-term termlist))) 
              (zero-terms? (rest-terms termlist))))) 
   (zero-terms? (term-list poly))) 

(put '=zero '(polynomial) =zero?)
...
)

2.87----------

如果有错的话,欢迎大家纠正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant