6 Commits bbf8ebcdf5 ... 84a326f5e7

Author SHA1 Message Date
  Samuel W. Flint 84a326f5e7 Add to-sexp for constants (handle resolution thereof) 1 year ago
  Samuel W. Flint 1e19ff9293 Add to-sexp for variables 1 year ago
  Samuel W. Flint 9fa51cca6d Add to-sexp for numbers 1 year ago
  Samuel W. Flint 712f3853ad Add `to-sexp` operation as part of protocol 1 year ago
  Samuel W. Flint 856588c413 Fix some stuff for trig 1 year ago
  Samuel W. Flint fbc0ac3aca Finish Trig types 1 year ago
1 changed files with 130 additions and 21 deletions
  1. 130 21
      larcs.org

+ 130 - 21
larcs.org

@@ -67,7 +67,7 @@ While the [[id:f3e3cdb9-a661-4598-8be1-e15f587f35bb][Introduction]] describes th
 #+TOC: headlines 3
 #+TOC: listings
 
-* WORKING Expression Types [2/4]
+* WORKING Expression Types [1/4]
 :PROPERTIES:
 :ID:       fe611e8f-db42-4fe0-8e77-9cfb55d2227c
 :END:
@@ -108,7 +108,10 @@ Note, by default, ~eqal~ will handle ~type-error~ by trying to switch the order
   (defgeneric evaluate (expression &key substitutions-list resolve-constants-light-p resolve-constants-hard-p))
 
   @export
-  (defgeneric simplify (expression &key resolve-constans-light-p resolve-constants-hard-p))
+  (defgeneric simplify (expression &key resolve-constants-light-p resolve-constants-hard-p))
+
+  @export
+  (defgeneric to-sexp (expression &optional resolve-constants-p))
 #+END_SRC
 
 #+Caption: Types
@@ -183,7 +186,7 @@ Of the various types, there are three atomic types, ~<number>~, ~<variable>~ and
 #+END_SRC
 
 *** DONE Numbers
-CLOSED: [2019-01-05 Sat 09:56]
+CLOSED: [2019-01-16 Wed 16:01]
 :PROPERTIES:
 :ID:       f0314608-46d9-4cc0-a3e1-897481827ddf
 :END:
@@ -204,10 +207,14 @@ As an ~<atomic>~, ~<number>~ is rather simple, having only one slot, ~value~, re
 
   (defmethod eqal ((expression-a <number>) (expression-b <number>))
     (= (value expression-a) (value expression-b)))
+
+  (defmethod to-sexp ((expression <number>) &optional resolve-constants-p)
+    (declare (ignorable resolve-constants-p))
+    (slot-value expression 'value))
 #+END_SRC
 
 *** DONE Variables
-CLOSED: [2019-01-05 Sat 09:56]
+CLOSED: [2019-01-16 Wed 16:13]
 :PROPERTIES:
 :ID:       f5f656d0-6253-4c4c-8c50-6622d685eaa1
 :END:
@@ -229,10 +236,14 @@ CLOSED: [2019-01-05 Sat 09:56]
   (defmethod eqal ((expression-a <variable>) (expression-b <variable>))
     (equalp (value expression-a)
             (value expression-b)))
+
+  (defmethod to-sexp ((expression <variable>) &optional resolve-constants-p)
+    (declare (ignore resolve-constants-p))
+    (slot-value expression 'name))
 #+END_SRC
 
 *** DONE Constants
-CLOSED: [2019-01-05 Sat 12:07]
+CLOSED: [2019-01-16 Wed 16:23]
 :PROPERTIES:
 :ID:       806bbce0-ab52-411a-8178-29bda6bbb36a
 :END:
@@ -271,9 +282,14 @@ Equality of constants is a bit different, and is checked as follows:
   (defmethod eqal ((expression-a <constant>) (expression-b <number>))
     (= (slot-value expression-a 'value)
        (slot-value expression-b 'value)))
+
+  (defmethod to-sexp ((expression <constant>) &optional resolve-constants-p)
+    (if resolve-constants-p
+        (slot-value expression 'value)
+        (slot-value expression 'name)))
 #+END_SRC
 
-** WORKING Compound Types [6/7]
+** WORKING Compound Types [0/7]
 :PROPERTIES:
 :ID:       a0d2eb19-8a1e-4dee-9b41-c454a49cacc4
 :END:
@@ -291,8 +307,7 @@ Compound types are the majority of expressions.  An atom is well and good, but o
     nil)
 #+END_SRC
 
-*** DONE Additions
-CLOSED: [2019-01-05 Sat 16:00]
+*** WORKING Additions
 :PROPERTIES:
 :ID:       a1a01fb4-59e1-4459-9ab9-d32269af77dd
 :END:
@@ -317,8 +332,7 @@ CLOSED: [2019-01-05 Sat 16:00]
                                :test #'eqal)))))
 #+END_SRC
 
-*** DONE Subtractions
-CLOSED: [2019-01-05 Sat 16:41]
+*** WORKING Subtractions
 :PROPERTIES:
 :ID:       aad16971-81c8-48da-aaa5-bb84b03d6912
 :END:
@@ -345,8 +359,7 @@ Subtractions again, contain only a list of terms.  However, unlike other types h
               ((or (not keep) (null a) (null b)) keep)))))
 #+END_SRC
 
-*** DONE Multiplications
-CLOSED: [2019-01-05 Sat 12:17]
+*** WORKING Multiplications
 :PROPERTIES:
 :ID:       0c601f5c-a614-4c30-9107-220a5d45a334
 :END:
@@ -369,8 +382,7 @@ Multiplication is one of the more frequently used expression types, and is, surp
                              :test #'eqal))))
 #+END_SRC
 
-*** DONE Divisions
-CLOSED: [2019-01-05 Sat 12:25]
+*** WORKING Divisions
 :PROPERTIES:
 :ID:       bcc56ff0-0a6f-4eb6-8185-2cab3eed99da
 :END:
@@ -396,8 +408,7 @@ Division is similar to ~<multiplication>~, although instead of having ~terms~ it
                (div-denominator expression-b))))
 #+END_SRC
 
-*** DONE Exponentials
-CLOSED: [2019-01-05 Sat 15:28]
+*** WORKING Exponentials
 :PROPERTIES:
 :ID:       d8c87457-5c3b-4263-ba60-53b9b9f5e816
 :END:
@@ -434,8 +445,7 @@ There are two primary forms of exponential -- the natural (~exp~) and the genera
                    :value 2.71828))
 #+END_SRC
 
-*** DONE Logarithmics
-CLOSED: [2019-01-05 Sat 15:47]
+*** WORKING Logarithmics
 :PROPERTIES:
 :ID:       7d4a23af-6c6b-4ae3-a8af-e477cbee9082
 :END:
@@ -472,10 +482,108 @@ CLOSED: [2019-01-05 Sat 15:47]
              (log-of expression-b))))
 #+END_SRC
 
-*** TODO Trigonometric
+*** WORKING Trigonometric
+:PROPERTIES:
+:ID:       adbef278-121d-4ef4-a607-7fc129d4d6ea
+:END:
+
+Trigonemtric functions are also a bit weird -- as given a "normal" trig function, /e.g.,/ $\sin{\theta}$, there's the normal, the inverse, the hyperbolic, and the hyperbolic inverse.  As such, we have a superclass for each, and then equality, which checks type and ~eqal~-ness of the inner expression.
+
+#+Caption: Trig Bases
+#+Name: type-trigs
+#+BEGIN_SRC lisp 
+  @export
+  (defclass <trig> (<expression>)
+    ((expression :reader expression
+                 :initarg :expression
+                 :type <expression>)))
+
+  @export
+  (defclass <inverse-trig> (<trig>) ())
+
+  @export
+  (defclass <hyperbolic-trig> (<trig>) ())
+
+  (defmethod eqal ((expression-a <trig>) (expression-b <trig>))
+    (and (equalp (type-of expression-a)
+               (type-of expression-b))
+       (eqal (expression expression-a)
+             (expression expression-b))))
+
+  @export
+  (defclass <sin> (<trig>) ())
+
+  @export
+  (defclass <cos> (<trig>) ())
+
+  @export
+  (defclass <tan> (<trig>) ())
+
+  @export
+  (defclass <csc> (<trig>) ())
+
+  @export
+  (defclass <sec> (<trig>) ())
+
+  @export
+  (defclass <cot> (<trig>) ())
+
+  @export
+  (defclass <asin> (<inverse-trig>) ())
+
+  @export
+  (defclass <acos> (<inverse-trig>) ())
+
+  @export
+  (defclass <atan> (<inverse-trig>) ())
+
+  @export
+  (defclass <acsc> (<inverse-trig>) ())
+
+  @export
+  (defclass <asec> (<inverse-trig>) ())
+
+  @export
+  (defclass <acot> (<inverse-trig>) ())
+
+  @export
+  (defclass <sinh> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <cosh> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <tanh> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <csch> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <sech> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <coth> (<hyperbolic-trig>) ())
+
+  @export
+  (defclass <asinh> (<hyperbolic-trig> <inverse-trig>) ())
+
+  @export
+  (defclass <acosh> (<hyperbolic-trig> <inverse-trig>) ())
+
+  @export
+  (defclass <atanh> (<hyperbolic-trig> <inverse-trig>) ())
+
+  @export
+  (defclass <acsch> (<hyperbolic-trig> <inverse-trig>) ())
+
+  @export
+  (defclass <asech> (<hyperbolic-trig> <inverse-trig>) ())
+
+  @export
+  (defclass <acoth> (<hyperbolic-trig> <inverse-trig>) ())
+#+END_SRC
 
-** DONE Blended Types -- Polynomial Terms
-CLOSED: [2019-01-05 Sat 09:46]
+** WORKING Blended Types -- Polynomial Terms
 :PROPERTIES:
 :ID:       a7258c20-bdd1-4565-9ada-41026ea5e1a0
 :END:
@@ -1382,6 +1490,7 @@ As all of the packages are defined centrally, this makes resolving inter-package
   <<type-division>>
   <<type-exponentials>>
   <<type-logarithmics>>
+  <<type-trigs>>
 
   <<type-poly-term>>
 #+END_SRC