Browse Source

Set most marked DONE to WORKING, write `eqal` for <multiplications>

Samuel W. Flint 5 years ago
parent
commit
183873cc59
1 changed files with 12 additions and 8 deletions
  1. 12 8
      larcs.org

+ 12 - 8
larcs.org

@@ -427,7 +427,7 @@ Equality of constants is a bit different, and is checked as follows:
        (slot-value expression-b 'value)))
 #+END_SRC
 
-** WORKING Compound Types [3/7]
+** WORKING Compound Types [1/7]
 
 Compound types are the majority of expressions.  An atom is well and good, but often says relatively little.  We use compound types to form equations from other expressions.  These are not, then, ~atomicp~.
 
@@ -442,21 +442,26 @@ Compound types are the majority of expressions.  An atom is well and good, but o
 #+END_SRC
 
 *** DONE Multiplications
-CLOSED: [2019-01-05 Sat 09:01]
+CLOSED: [2019-01-05 Sat 12:17]
 
-Multiplication is one of the more frequently used expression types, and is, surprisingly, simple.  A ~<multiplication>~ has only one slot, ~terms~, the various expressions to be multiplied.
+Multiplication is one of the more frequently used expression types, and is, surprisingly, simple.  A ~<multiplication>~ has only one slot, ~terms~, the various expressions to be multiplied.  Further, if two ~<multiplication>~ objects have the same number of terms, and there is no ~set-difference~ given ~eqal~ between the two lists of terms, the two ~<multiplication>~ objects are ~eqal~.
 
 #+Caption: Multiplications
 #+Name: type-multiplications
 #+BEGIN_SRC lisp 
   (defclass <multiplication> (<compound>)
     ((terms :reader terms
-            :initarg terms
+            :initarg :terms
             :type (list <expression>))))
+
+  (defmethod eqal ((expression-a <multiplication>) (expression-b <multiplication>))
+    (and (= (length (terms expression-a))
+          (length (terms expression-b)))
+       (null (set-difference (terms expression-a) (terms expression-b)
+                             :test #'eqal))))
 #+END_SRC
 
-*** DONE Divisions
-CLOSED: [2019-01-05 Sat 09:09]
+*** WORKING Divisions
 
 Division is similar to ~<multiplication>~, although instead of having ~terms~ it has ~numerator~ and ~denominator~.
 
@@ -472,8 +477,7 @@ Division is similar to ~<multiplication>~, although instead of having ~terms~ it
                   :type <expression>)))
 #+END_SRC
 
-*** DONE Exponentials
-CLOSED: [2019-01-05 Sat 09:20]
+*** WORKING Exponentials
 
 There are two primary forms of exponential -- the natural (~exp~) and the general (~expt~).  Given this, there are two classes, with ~<exp>~ being a subclass of ~<expt>~, mirroring the generality of exponentials in general.