A simple polynomial calculator in lisp

poly.cl 727B

12345678910111213141516171819202122232425
  1. (defun poly+ (poly1 poly2)
  2. (format t "Poly One: ~d~%" poly1)
  3. (format t "Poly Two: ~d~%" poly2)
  4. (if (equal (length poly1) 1)
  5. (format t "Poly 1 has exactly one term: ~a Ex: ~a Mul: ~a~%"
  6. (find-variable-symbol poly1)
  7. (find-exponent poly1)
  8. (find-multiplier poly1))
  9. (format t "Poly 1 has more than one term~%")))
  10. (defun collect-like-terms (poly)
  11. (format t "collecting terms"))
  12. (defun find-variable-symbol (single-poly)
  13. (car (car (car single-poly))))
  14. (defun find-exponent (single-poly)
  15. (cdr (car (car single-poly))))
  16. (defun find-multiplier (single-poly)
  17. (cdr (car single-poly)))
  18. (poly+ '(((x 2) 3)) '(((y 2) 4)))
  19. (poly+ '(((x 2) 3) ((y 2) 3)) '(((y 2) 4)))