ソースを参照

Add more tests and improved README

Matt Coles 10 年 前
コミット
d759090578
共有2 個のファイルを変更した16 個の追加2 個の削除を含む
  1. 6 2
      README.md
  2. 10 0
      tests.cl

+ 6 - 2
README.md

@@ -1,2 +1,6 @@
1
-# lisp-poly-calculator
2
-A simple polynomial calculator in lisp
1
+# LISP Polynomial Calculator
2
+* A simple polynomial calculator in lisp
3
+* Polynomials are in the form 
4
+    '(((SYMBOL EXPONENT) MULTIPLIER) ((SYMBOL EXPONENT) MULTIPLIER))
5
+* For example this:
6
+    '(((x 2) 5) ((((x y) (2 3)) 5))) \= 5x^2 + 5x^2y^3

+ 10 - 0
tests.cl

@@ -21,4 +21,14 @@
21 21
         '(((z 3) -4) ((x 2) 2) ((y 2) 3)))
22 22
     (format t "5x^2+6y^2 - 3x^2+3y^2+4z^3 ... passed - complex subtraction~%")
23 23
     (format t "5x^2+6y^2 - 3x^2+3y^2+4z^3 ... failed - complex subtraction~%"))
24
+  (if (equal
25
+        (poly* '(((x 2) 5)) '(((x 2) 5)))
26
+        '(((x 4) 25)))
27
+    (format t "5x^2 * 5x^2 ... passed - simple multiplication~%")
28
+    (format t "5x^2 * 5x^2 ... failed - simple multiplication~%"))
29
+  (if (equal
30
+        (poly* '(((x 2) 5) ((y 2) 1)) '(((x 1) 3) ((y 1) 1)))
31
+        '(((X 3) 15) (((X Y) (2 1)) 5) (((Y X) (2 1)) 3) ((Y 3) 1)))
32
+    (format t "(5x^2+y^2) * (3x + y) ... passed - complex multiplication~%")
33
+    (format t "(5x^2+y^2) * (3x + y) ... failed - complex multiplication~%"))
24 34
   )