|
@@ -372,6 +372,14 @@ Compound types are the majority of expressions. An atom is well and good, but o
|
|
|
(defmethod copy-expression ((expression <addition>))
|
|
|
(make-instance '<addition>
|
|
|
:terms (mapcar #'copy-expression (slot-value expression 'terms))))
|
|
|
+
|
|
|
+ (defmethod substitute-expression (replace replacement (expression <addition>))
|
|
|
+ (if (eqal expression replace)
|
|
|
+ replacement
|
|
|
+ (make-instance '<addition>
|
|
|
+ :terms (mapcar #'(lambda (exp)
|
|
|
+ (substitute-expression replace replacement exp))
|
|
|
+ (slot-value expression 'terms)))))
|
|
|
#+END_SRC
|
|
|
|
|
|
*** WORKING Subtractions
|