A simple polynomial calculator in lisp

poly.cl 539B

12345678910111213141516171819202122232425
  1. (defun poly+ (poly1 poly2)
  2. (add-terms poly1 poly2))
  3. (defun variable-symbol (single-poly)
  4. (car (car (car single-poly))))
  5. (defun exponent (single-poly)
  6. (cdr (car (car single-poly))))
  7. (defun multiplier (single-poly)
  8. (cdr (car single-poly)))
  9. (defun is-single-poly (var-poly)
  10. (if (equal (length var-poly) 1) T nil))
  11. (defun add-terms (poly1 poly2)
  12. (if (equal (is-single-poly poly1) (is-single-poly poly2))
  13. (cons poly1 poly2)
  14. (progn
  15. )
  16. ))
  17. (poly+ '(((x 2) 3)) '(((y 2) 4)))
  18. ; (poly+ '(((x 2) 3) ((y 2) 3)) '(((y 2) 4)))