A simple polynomial calculator in lisp

tests.cl 1016B

12345678910111213141516171819202122232425
  1. (require "poly.cl")
  2. (defun run-tests ()
  3. (if (equal
  4. (poly+ '(((x 2) 5)) '(((x 2) 3)))
  5. '(((x 2) 8)))
  6. (format t "5x^2 + 3x^2 ... passed - simple addition~%")
  7. (format t "5x^2 + 3x^2 ... failed - simple addition~%"))
  8. (if (equal
  9. (poly+ '(((x 2) 5) ((y 2) 6)) '(((x 2) 3) ((y 2) 3) ((z 3) 4)))
  10. '(((z 3) 4) ((x 2) 8) ((y 2) 9)))
  11. (format t "5x^2+6y^2 + 3x^2+3y^2+4z^3 ... passed - complex addition~%")
  12. (format t "5x^2+6y^2 + 3x^2+3y^2+4z^3 ... failed - complex addition~%"))
  13. (if (equal
  14. (poly- '(((x 2) 5)) '(((x 2) 3)))
  15. '(((x 2) 2)))
  16. (format t "5x^2 - 3x^2 ... passed - simple subtraction~%")
  17. (format t "5x^2 - 3x^2 ... failed - simple subtraction~%"))
  18. (if (equal
  19. (poly- '(((x 2) 5) ((y 2) 6)) '(((x 2) 3) ((y 2) 3) ((z 3) 4)))
  20. '(((z 3) -4) ((x 2) 2) ((y 2) 3)))
  21. (format t "5x^2+6y^2 - 3x^2+3y^2+4z^3 ... passed - complex subtraction~%")
  22. (format t "5x^2+6y^2 - 3x^2+3y^2+4z^3 ... failed - complex subtraction~%"))
  23. )