Ver código fonte

Switched to using classification-case

Samuel W. Flint 8 anos atrás
pai
commit
4c43365fc1
1 arquivos alterados com 15 adições e 15 exclusões
  1. 15 15
      manipulation.org

+ 15 - 15
manipulation.org

@@ -569,26 +569,26 @@ Foo
 #+BEGIN_SRC lisp
   (defun coefficient (term)
     (when (classified-as-p term 'polynomial-term)
-      (cond
-        ((classified-as-p term 'variable) 1)
-        ((classified-as-p term 'power) 1)
-        ((classified-as-p term 'multiplicative) (second term))
-        ((classified-as-p term 'numeric) term))))
+      (classification-case term
+                           (variable 1)
+                           (power 1)
+                           (multiplicative (second term))
+                           (numeric term))))
 
   (defun term-variable (term)
     (when (classified-as-p term 'polynomial-term)
-      (cond
-        ((classified-as-p term 'multiplicative) (second (third term)))
-        ((classified-as-p term 'power) (second term))
-        (t nil))))
+      (classification-case term
+                           (multiplicative (second (third term)))
+                           (power (second term))
+                           (* nil))))
 
   (defun get-power (term)
-    (cond
-      ((classified-as-p term 'numeric) 0)
-      ((classified-as-p term 'variable) 1)
-      ((classified-as-p term 'power) (third term))
-      ((classified-as-p term 'polynomial-term) (third (third term)))
-      (t 0)))
+    (classification-case term
+                         (numeric 0)
+                         (variable 1)
+                         (power (third term))
+                         (polynomial-term (third (third term)))
+                         (* 0)))
 
   (defun same-order-p (term-a term-b)
     (= (get-power term-a)