Browse Source

Wrote about classification case

Samuel W. Flint 9 years ago
parent
commit
764de0bfca
1 changed files with 8 additions and 4 deletions
  1. 8 4
      manipulation.org

+ 8 - 4
manipulation.org

@@ -53,7 +53,7 @@ As a part of my lisp-based Computer Algebra System, an algebraic manipulation to
 #+TOC: headlines 3
 #+TOC: listings
 
-* WORKING Expression Typing [4/6]
+* WORKING Expression Typing [5/6]
 :PROPERTIES:
 :CREATED:  <2016-04-30 Sat 23:15>
 :ID:       c6921b1e-d269-4243-acff-5a77685c331e
@@ -144,12 +144,15 @@ To completely classify an expression, the ~*classifications*~ alist is mapped ov
             (push name classifications))))))
 #+END_SRC
 
-** WORKING Classification Case
+** DONE Classification Case
+CLOSED: [2016-05-30 Mon 18:17]
 :PROPERTIES:
 :CREATED:  <2016-05-20 Fri 14:15>
 :ID:       19a4e467-baa0-47eb-9267-93ff3801b1fd
 :END:
 
+Following the case pattern, and to allow for cleaner code, I've defined the classification case macro.  It does this by taking a variable name and a list of cases.  These are then mapped over, producing clauses suitable for a ~cond~ expression, to which this macro finally expands, binding the complete classification of the given expression to ~the-classification~.
+
 #+Caption: Classification Case
 #+Name: classification-case
 #+BEGIN_SRC lisp
@@ -161,8 +164,9 @@ To completely classify an expression, the ~*classifications*~ alist is mapped ov
                                            `((classified-as-p ,var '*) ,@body)
                                            `((classified-as-p ,var ',type) ,@body))))
                            cases)))
-      `(cond
-         ,@conditions)))
+      `(let ((the-classification (classify ,var)))
+         (cond
+           ,@conditions))))
 #+END_SRC
 
 ** WORKING Classifications [7/13]