Browse Source

Add expression substitution for subtractions

Samuel W. Flint 4 years ago
parent
commit
64f984a29a
1 changed files with 8 additions and 0 deletions
  1. 8 0
      larcs.org

+ 8 - 0
larcs.org

@@ -415,6 +415,14 @@ Subtractions again, contain only a list of terms.  However, unlike other types h
   (defmethod copy-expression ((expression <subtraction>))
     (make-instance '<subtraction>
                    :terms (mapcar #'copy-expression (slot-value expression 'terms))))
+
+  (defmethod substitute-expression (replace replacement (expression <subtraction>))
+    (if (eqal replace expression)
+        replacement
+        (make-instance '<subtraction>
+                       :terms (mapcar #'(lambda (exp)
+                                          (substitute-expression replace replacement exp))
+                                      (slot-value expression 'terms)))))
 #+END_SRC
 
 *** WORKING Multiplications