9 Commits a4a866e916 ... bbf8ebcdf5

Author SHA1 Message Date
  Samuel W. Flint bbf8ebcdf5 Archived some old "common functionality" 5 years ago
  Samuel W. Flint dc56f8c4a4 Add subtractions handling and re-order 5 years ago
  Samuel W. Flint aa34602083 Write additions definition 5 years ago
  Samuel W. Flint 4e0d92dcb8 Wrote Logarithmic types 5 years ago
  Samuel W. Flint e270d966d5 Work on some packaging stuff, incl writing eqal for <expt> 5 years ago
  Samuel W. Flint c043bf3f72 `eqal`ity of divisions are done 5 years ago
  Samuel W. Flint 183873cc59 Set most marked DONE to WORKING, write `eqal` for <multiplications> 5 years ago
  Samuel W. Flint 65eea6a6e2 And all Atomic types are done 5 years ago
  Samuel W. Flint cb3f1bdda7 Fix eqal, as well as name of substitute, now substitute-expression 5 years ago
2 changed files with 893 additions and 726 deletions
  1. 181 726
      larcs.org
  2. 712 0
      larcs.org_archive

File diff suppressed because it is too large
+ 181 - 726
larcs.org


+ 712 - 0
larcs.org_archive

@@ -939,3 +939,715 @@ To be able to apply an expansion, you need to determine eligibility.  To do this
            (>= ,arg-count-var ,arity)))))
 #+END_SRC
 
+
+* WORKING Common Functionality [3/6]
+:PROPERTIES:
+:CREATED:  <2016-06-11 Sat 22:23>
+:ID:       f153a0fe-ec04-47b1-bdc5-290cc62bc985
+:ARCHIVE_TIME: 2019-01-05 Sat 16:55
+:ARCHIVE_FILE: ~/Projects/larcs/larcs.org
+:ARCHIVE_CATEGORY: larcs
+:ARCHIVE_TODO: WORKING
+:END:
+
+There are several bits of common functions or variables that are required for use.  This primarily includes functions that some of the macros rely on, or things that are required for use in other parts of the system, but don't present as specific functionality.
+
+** DONE Generate an Args List
+CLOSED: [2016-07-30 Sat 16:08]
+:PROPERTIES:
+:CREATED:  <2016-06-13 Mon 17:19>
+:ID:       49596957-2fc6-4458-ad85-99cbcf337b42
+:END:
+
+For some macros, an arguments list must be generated.  This is done by generating a list of variables starting with the word ~expression-~ followed by a letter from the alphabet, in turn.
+
+#+Caption: Generate an Args List
+#+Name: common-generate-an-args-list
+#+BEGIN_SRC lisp
+  (defun gen-args-list (count)
+    (let ((letters '(a b c d e f g h i j k l m n o p q r s t u v w x y z)))
+      (let ((variables-list '()))
+        (dotimes (i count)
+          (pushnew (symbolicate 'expression- (nth i letters)) variables-list))
+        (reverse variables-list))))
+#+END_SRC
+
+** DONE Constants and Greeks
+CLOSED: [2016-08-05 Fri 21:32]
+:PROPERTIES:
+:CREATED:  <2016-06-13 Mon 20:57>
+:ID:       907fcf64-51eb-4a2c-a8bc-29e4f75f1dd3
+:END:
+
+This is a mapping between the names of constants and the way that they are correctly displayed in TeX.  Besides defining the mapping, which is in the form of an alist, it also collects the names of all of the constants, and exports the names themselves.
+
+#+Caption: Constants and Greeks
+#+Name: constants-and-greeks
+#+BEGIN_SRC lisp
+  (defvar *special-symbols-to-sequences*
+    '((alpha . "\\alpha")
+      (beta . "\\beta")
+      (gamma . "\\gamma")
+      (delta . "\\delta")
+      (epsilon . "\\epsilon")
+      (varepsilon . "\\varepsilon")
+      (zeta . "\\zeta")
+      (eta . "\\eta")
+      (theta . "\\theta")
+      (vartheta . "\\vartheta")
+      (gamma . "\\gamma") (kappa . "\\kappa")
+      (lambda . "\\lambda")
+      (mu . "\\mu")
+      (nu . "\\nu")
+      (xi . "\\xi")
+      (omicron . "\\o")
+      (pi . "\\pi")
+      (varpi . "\\varpi")
+      (rho . "\\rho")
+      (varrho . "\\varrho")
+      (sigma . "\\sigma")
+      (varsigm . "\\varsigm")
+      (tau . "\\tau")
+      (upsilon . "\\upsilon")
+      (phi . "\\phi")
+      (varphi . "\\varphi")
+      (chi . "\\chi")
+      (psi . "\\psi")
+      (omega . "\\omega")
+      (big-gamma . "\\Gamma")
+      (big-delta . "\\Delta")
+      (big-theta . "\\Theta")
+      (big-lambda . "\\Lambda")
+      (big-xi . "\\Xi")
+      (big-pi . "\\Pi")
+      (big-sigma . "\\Sigma")
+      (big-upsilon . "\\Upsilon")
+      (big-phi . "\\Phi")
+      (big-psi . "\\Psi")
+      (big-omega . "\\Omega")))
+
+  (defvar *constant-names*
+    (mapcar #'car *special-symbols-to-sequences*))
+
+  (mapcar #'export *constant-names*)
+#+END_SRC
+
+** TODO Aget
+:PROPERTIES:
+:CREATED:  <2016-10-23 Sun 11:14>
+:END:
+
+#+Caption: Aget
+#+Name: common-aget
+#+BEGIN_SRC lisp
+  (defun aget (place indicator &optional default)
+    "
+  RETURN:   The value of the entry INDICATOR of the a-list PLACE, or DEFAULT.
+  "
+    (let ((a (assoc indicator place)))
+      (if a (cdr a) default)))
+
+  (define-setf-expander aget (place indicator &optional default &environment env)
+    (declare (ignore default))
+    (multiple-value-bind (vars vals store-vars writer-form reader-form)
+        (get-setf-expansion place env)
+      (let* ((vindicator (gensym "INDICATOR"))
+             (vvalue     (gensym "VALUE"))
+             (vstore     (first store-vars))
+             (acs        (gensym "PAIR")))
+        (values (list* vindicator vars)
+                (list* indicator  vals)
+                (list  vvalue)
+                `(let* ((,acs (assoc ,vindicator ,reader-form)))
+                   (if ,acs
+                       (setf (cdr ,acs) ,vvalue)
+                       (let ((,vstore (acons ,vindicator ,vvalue ,reader-form)))
+                         ,writer-form))
+                   ,vvalue)
+                `(assoc ,vindicator ,reader-form)))))
+#+END_SRC
+
+** TODO Ensure List
+:PROPERTIES:
+:CREATED:  <2016-10-23 Sun 11:17>
+:ID:       08d8e031-a30f-41b6-9981-caec2f07f2a0
+:END:
+
+#+Caption: Ensure List
+#+Name: ensure-list
+#+BEGIN_SRC lisp
+  (defun ensure-list (object)
+    "
+  RETURN:         If OBJECT is a list then OBJECT, otherwise a fresh
+                  list containing OBJECT.
+  "
+    (if (listp object) object (list object)))
+#+END_SRC
+
+** TODO Evaluating Bind
+:PROPERTIES:
+:CREATED:  <2016-12-14 Wed 15:13>
+:ID:       390707cd-6a58-404c-b2e5-286f09be977f
+:END:
+
+#+Caption: Evaluating Bind
+#+Name: evaluating-bind
+#+BEGIN_SRC lisp 
+  (defun evaluating-bind (expression &rest pairs)
+    (let ((vars (mapcar #'first pairs))
+          (values (mapcar #'second pairs)))
+      (apply (eval `(lambda ,vars ,expression)) values)))
+#+END_SRC
+
+** DONE Assembly
+CLOSED: [2016-07-30 Sat 15:43]
+:PROPERTIES:
+:CREATED:  <2016-06-13 Mon 17:20>
+:ID:       d583d5e4-a2c9-432c-9486-cc6baa4239f4
+:END:
+
+This is where the common functions and constants are assembled into their own package.  Almost all of the functions and variables are exported and available for everything else.
+
+#+Caption: Assemble Common Functions
+#+Name: assemble-common-functions
+#+BEGIN_SRC lisp :tangle "larcs-common.lisp"
+  (in-package #:larcs.common)
+
+  <<common-generate-an-args-list>>
+
+  <<constants-and-greeks>>
+
+  <<aget>>
+
+  <<ensure-list>>
+
+  <<evaluating-bind>>
+#+END_SRC
+
+
+* WORKING Symbolic To Typeset Form [0/5]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:13>
+:ID:       75f65e8a-0cc9-477f-b5e9-3c563fe7ef5c
+:ARCHIVE_TIME: 2019-01-05 Sat 16:56
+:ARCHIVE_FILE: ~/Projects/larcs/larcs.org
+:ARCHIVE_CATEGORY: larcs
+:ARCHIVE_TODO: WORKING
+:END:
+
+One of the less important parts of this system is the format converter, which converts between the internal symbolic form and a format that is capable of being typeset using TeX.  This is done using a variant of the common rewrite system, but instead of going between variants of the symbolic format, it converts from a symbolic format to string-based format.
+
+** WORKING Rule Management [0/2]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:17>
+:END:
+
+To accomplish the task of conversion from symbolic form to typeset form, rules are necessary.  It is done using three main things, rule definition, rule retrieval and rule storage.
+
+*** TODO Define Rules
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:18>
+:ID:       ec6fdb0d-546e-41fc-a7b7-5fbbfe4b7931
+:END:
+
+Rule definitions are built using the ~define-converter~ macro, which takes an expression type, a lambda list and a body.  It creates a function using the body and the given arguments list, and if it hasn't been pushed onto the storage system, the converter function is pushed into storage.
+
+#+Caption: Rule Definition
+#+Name: stf-define-rule
+#+BEGIN_SRC lisp
+  (defvar *rules* '())
+
+  (defmacro define-converter (expression-type (&rest arguments-list) &body body)
+    (let ((expansion-name (symbolicate expression-type '-conversion)))
+      `(progn
+         (when (not (member ',expression-type (mapcar #'car *rules*)))
+           (setq *rules* (append *rules* '((,expression-type . ,expansion-name)))))
+         (defun ,expansion-name (,@arguments-list)
+           ,@body))))
+#+END_SRC
+
+*** TODO Rule Retrieval
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:18>
+:ID:       0c34c744-7847-46c2-bdef-228feee7c84e
+:END:
+
+Rule retrieval is done by taking an expression, comparing it against given classifications, and from the first classification, returning the second element of the ~(classification . converter)~ pair.
+
+#+Caption: Rule Retrieval
+#+Name: stf-rule-retrieval
+#+BEGIN_SRC lisp
+  (defun get-rule (expression)
+    (cdr (first (remove-if #'(lambda (pair)
+                               (let ((type (first pair)))
+                                 (not (classified-as-p expression type))))
+                           ,*rules*))))
+#+END_SRC
+
+** WORKING Rules [0/9]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:18>
+:ID:       90accad9-81d0-4aaf-9c7f-2418e36e1f3c
+:END:
+
+The following contains all of the defined rules, which are as follows:
+
+ - Numerics
+ - Variables
+ - Polynomial Terms
+ - Multiplicatives
+ - Rationals
+ - Additives
+ - Subtractives
+ - Trigonometrics
+ - Exponentials & Logarithmics
+
+#+Caption: Rules
+#+Name: stf-rules
+#+BEGIN_SRC lisp
+  <<stf-numerics>>
+  <<stf-variables>>
+  <<stf-polynomial-terms>>
+  <<stf-multiplicatives>>
+  <<stf-rationals>>
+  <<stf-additives>>
+  <<stf-subtractives>>
+  <<stf-trigonometrics>>
+  <<stf-exponentials-logarithmics>>
+#+END_SRC
+
+*** TODO Numbers
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:22>
+:ID:       fbc3e5ac-3276-4f54-b53e-9d4cc0263405
+:END:
+
+Numbers are formatted fairly simply, as they are simply surrounded by curly braces, and formatted as to be normal read syntax, which is generally correct.
+
+#+Caption: Numerics
+#+Name: stf-numerics
+#+BEGIN_SRC lisp
+  (define-converter numeric (number)
+    (with-tex-output
+      (format nil "{~A}" number)))
+#+END_SRC
+
+*** TODO Variables
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:22>
+:ID:       8ec363f7-da0f-4023-90bb-e08a85623f55
+:END:
+
+As with numbers, variables are a relatively simple thing to format.  If the variable passed is in the ~*constant-names*~ list, then it must be a formattable constant for which there is a known TeX command.  If there is, it is looked up in the ~*special-symbols-to-sequences*~ alist, otherwise, the given variable is downcased and output as a string.  Either way, they are surrounded by, as usual, curly braces.
+
+#+Caption: Variables
+#+Name: stf-variables
+#+BEGIN_SRC lisp
+  (define-converter variable (var)
+    (if (member var *constant-names*)
+        (with-tex-output
+          (format nil "{~A}" (cdr (assoc var *special-symbols-to-sequences*))))
+        (with-tex-output
+          (format nil "{~A}" (string-downcase var)))))
+#+END_SRC
+
+*** TODO Polynomial Terms
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:23>
+:ID:       ac2283d0-da70-4672-90cb-08511bd9105e
+:END:
+
+Polynomial Terms are a specific classification, defined as follows:
+
+ - A variable, raised to a numeric power.
+ - A number, followed by a single variable.
+ - A number, followed by a variable raised to a numeric power.
+
+These are typeset as a single unit, ensuring readability.
+
+#+Caption: Polynomial Terms
+#+Name: stf-polynomial-terms
+#+BEGIN_SRC lisp
+  (define-converter polynomial-term (&rest term)
+    (let ((variable (term-variable term))
+          (coefficient (coefficient term))
+          (power (get-power term)))
+      (cond
+        ((= 1 power)
+         (with-tex-output
+           (format nil "{~A}{~A}"
+                   (convert-for-display coefficient)
+                   (convert-for-display power))))
+        ((= 0 coefficient)
+         (with-tex-output
+           (format nil "{~A}^{~A}"
+                   (convert-for-display variable)
+                   (convert-for-display power))))
+        (t
+         (with-tex-output
+           (format nil "{~A}{~A}^{~A}"
+                   (convert-for-display coefficient)
+                   (convert-for-display variable)
+                   (convert-for-display power)))))))
+#+END_SRC
+
+*** TODO Multiplicatives
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:23>
+:ID:       87a7e236-072e-4c19-9f09-c458e5b50397
+:END:
+
+In the case of multiplicatives, which are variadic, a $\cdot$ or ~\cdot~ is placed in between each term, individually converted itself.
+
+#+Caption: Multiplicatives
+#+Name: stf-multiplicatives
+#+BEGIN_SRC lisp
+  (define-converter multiplicative (op &rest elements)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~{~A~^ \\cdot ~}}"
+              (mapcar #'convert-for-display
+                      elements))))
+#+END_SRC
+
+*** TODO Rationals
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:23>
+:ID:       4f8f984f-e567-4efb-ba15-8a98e15915fe
+:END:
+
+#+Caption: Rationals
+#+Name: stf-rationals
+#+BEGIN_SRC lisp
+  (define-converter rational (op numerator denominator)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\frac{~A}{~A}}"
+              (convert-for-display numerator)
+              (convert-for-display denominator))))
+#+END_SRC
+
+*** TODO Additives
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:23>
+:ID:       10ec8596-094a-4900-aba0-22b958ffdc9a
+:END:
+
+#+Caption: Additives
+#+Name: stf-additives
+#+BEGIN_SRC lisp
+  (define-converter additive (op &rest terms)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~{~A~^ + ~}}"
+              (mapcar #'convert-for-display terms))))
+#+END_SRC
+
+*** TODO Subtractives
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:23>
+:ID:       1037cb8e-f127-4c87-9312-2817bc2cfc25
+:END:
+
+#+Caption: Subtractives
+#+Name: stf-subtractives
+#+BEGIN_SRC lisp
+  (define-converter subtractive (op &rest terms)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~{~A~^ - ~}}"
+              (mapcar #'convert-for-display terms))))
+#+END_SRC
+
+*** TODO Trigonometrics
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 18:38>
+:ID:       742d303a-dcea-4bb2-9553-19b968a70272
+:END:
+
+#+Caption: Trigonometrics
+#+Name: stf-trigonometrics
+#+BEGIN_SRC lisp
+  (define-converter sin (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\sin {~A}}" (convert-for-display term))))
+
+  (define-converter cos (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\cos {~A}}" (convert-for-display term))))
+
+  (define-converter tan (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\tan {~A}}" (convert-for-display term))))
+
+  (define-converter csc (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\csc {~A}}" (convert-for-display term))))
+
+  (define-converter sec (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\sec {~A}}" (convert-for-display term))))
+
+  (define-converter cot (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\cot {~A}}" (convert-for-display term))))
+#+END_SRC
+
+*** TODO Exponentials and Logarithmics
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:24>
+:ID:       24dc527f-0b9d-44b0-ae0f-4515f0c1d119
+:END:
+
+#+Caption: Exponentials and Logarithmics
+#+Name: stf-exponentials-logarithmics
+#+BEGIN_SRC lisp
+  (define-converter natural-exponential (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{e^~A}" (convert-for-display term))))
+
+  (define-converter exponential (op base power)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~A^~A}"
+              (convert-for-display base)
+              (convert-for-display power))))
+
+  (define-converter natural-logarithmic (op term)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\ln ~A}"
+              (convert-for-display term))))
+
+  (define-converter logarithmic (op term base)
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\log_~a ~a}"
+              (convert-for-display base)
+              (convert-for-display term))))
+#+END_SRC
+
+** WORKING Converter [2/7]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:18>
+:ID:       88d433ad-e381-4747-8a29-2d78bc759fbf
+:END:
+
+The ~convert-for-display~ function is the driver for this portion of the application, and, in general, uses the previously defined rules, save for the logical functions ~and~, ~or~, ~not~, and the equality operation, summation with big-Sigma, integration and parenthesis.
+
+#+Caption: Conversion Driver
+#+Name: stf-conversion-driver
+#+BEGIN_SRC lisp
+  (defun convert-for-display (function)
+    (if (and (listp function)
+           (member (first function) '(and or not = sum integrate parens)))
+        (let ((operator (first function)))
+          (cond
+            ((eq operator 'and)
+             <<stf-and-operator>>
+             )
+            ((eq operator 'or)
+             <<stf-or-operator>>
+             )
+            ((eq operator 'not)
+             <<stf-not-operator>>
+             )
+            ((eq operator '=)
+             <<stf-equality-operator>>
+             )
+            ((eq operator 'sum)
+             <<stf-summation>>
+             )
+            ((eq operator 'integrate)
+             <<stf-integration>>
+             )
+            ((eq operator 'parens)
+             <<stf-parenthesis>>
+             )))
+        (let ((rule (get-rule function)))
+          (when rule
+            (apply rule (ensure-list function))))))
+#+END_SRC
+
+*** DONE And
+CLOSED: [2016-12-09 Fri 15:20]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:38>
+:ID:       733b98a1-90f1-4d13-abe8-cb86a5608aee
+:END:
+
+Like other rules, this formats a list of other sub-equations, with the symbol $\land$ (~\land~) between each term.
+
+#+Caption: And Operator
+#+Name: stf-and-operator
+#+BEGIN_SRC lisp
+  (destructuring-bind (op &rest terms) function
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~{~A~^ \\wedge ~}}"
+              (mapcar #'convert-for-display terms))))
+#+END_SRC
+
+*** DONE Or
+CLOSED: [2016-12-09 Fri 15:22]
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:38>
+:ID:       276de305-32c4-4f79-96e7-d0a99ff24f78
+:END:
+
+This does the same thing as "And", replacing the symbol with $\lor$ (~\lor~).
+
+#+Caption: Or Operator
+#+Name: stf-or-operator
+#+BEGIN_SRC lisp
+  (destructuring-bind (op &rest terms) function
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{~{~A~^ \\vee ~}}"
+              (mapcar #'convert-for-display terms))))
+#+END_SRC
+
+*** TODO Not
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:38>
+:ID:       1b0a28a4-744d-44d1-a328-7b2bb10bd0c7
+:END:
+
+Foo
+
+#+Caption: Not Operator
+#+Name: stf-not-operator
+#+BEGIN_SRC lisp
+  (destructuring-bind (op term) function
+    (with-tex-output
+      (format nil "{\\not ~A}"
+              (convert-for-display term))))
+#+END_SRC
+
+*** TODO Equality
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:41>
+:ID:       4ce4835c-e196-4494-ab4b-591690e4164c
+:END:
+
+Foo
+
+#+Caption: Equality Operator
+#+Name: stf-equality-operator
+#+BEGIN_SRC lisp
+  (destructuring-bind (op lhs rhs) function
+    (declare (ignore op))
+    (format nil "{~A = ~A}"
+            (convert-for-display lhs)
+            (convert-for-display rhs)))
+#+END_SRC
+
+*** TODO Summation
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:24>
+:ID:       98404213-b8b8-410f-b660-23b701518cea
+:END:
+
+#+Caption: Summation
+#+Name: stf-summation
+#+BEGIN_SRC lisp
+  (destructuring-bind (op start stop expression) function
+    (declare (ignore op))
+    (format nil "{\sum_~A^~A ~A}"
+            (convert-for-display start)
+            (convert-for-display stop)
+            (convert-for-display expression)))
+#+END_SRC
+
+*** TODO Integration
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:39>
+:ID:       60c16d30-2bb3-497c-aaa0-4529ecfc523c
+:END:
+
+#+Caption: Integration
+#+Name: stf-integration
+#+BEGIN_SRC lisp
+  (destructuring-bind (op from to expression wrt) function
+    (declare (ignore op))
+    (with-tex-output
+      (format nil "{\\int_~A^~A ~A\\,\\mathrm{d}~A}"
+              (convert-for-display from)
+              (convert-for-display to)
+              (convert-for-display expression)
+              (convert-for-display wrt))))
+#+END_SRC
+
+*** TODO Parenthesis
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:24>
+:ID:       93d643d6-2219-4c49-bba5-190520a6ff29
+:END:
+
+#+Caption: Parenthesis
+#+Name: stf-parenthesis
+#+BEGIN_SRC lisp
+  (destructuring-bind (op type expression) function
+    (declare (ignore op))
+    (let* ((types '((square . ("[" . "]"))
+                    (curly . ("{" . "}"))
+                    (smooth . ("(" . ")"))))
+           (left (cadr (assoc type types)))
+           (right (cddr (assoc type types))))
+      (with-tex-output
+        (format nil "{\\left~a {~a} \\right~a}"
+                left
+                (convert-for-display expression)
+                right))))
+#+END_SRC
+
+** TODO Special Macros
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:20>
+:ID:       56ca6afe-912a-4530-91e4-a63123dc6d9d
+:END:
+
+There is one specialty macro, ~with-tex-output~, which is used to ensure that an expression is wrapped to be a part of correct (La)TeX output.  It works by checking to see whether or not the variable ~*tex-outputp*~ is true, if so, it simply pass through the given body, and if not, it binds the variable to ~t~, and makes sure that the given body is wrapped in ~$~, allowing the expression to be typeset correctly.
+
+#+Caption: Special Macros
+#+Name: stf-special-macros
+#+BEGIN_SRC lisp
+  (defvar *tex-outputp* nil)
+  (declaim (special *tex-outputp*))
+
+  (defmacro with-tex-output (&body body)
+    `(if *tex-outputp*
+         (progn
+           ,@body)
+         (let ((*tex-outputp* t))
+           (format nil "$~a$"
+                   (progn
+                     ,@body)))))
+#+END_SRC
+
+** TODO Assembly
+:PROPERTIES:
+:CREATED:  <2016-06-14 Tue 17:15>
+:ID:       bbd15b88-8256-4b5b-abcc-4783fc096c29
+:END:
+
+The final assembly of this portion of the system is as simple as the rest, resolving dependencies and placing everything in a single file.  As normal, this is done using NoWeb syntax, with everything tangled to the file ~larcs-typeset.lisp~.
+
+#+Caption: Assemble Symbolic to Typeset Form
+#+Name: stf-assemble
+#+BEGIN_SRC lisp :tangle "larcs-typeset.lisp"
+  (in-package #:larcs.typeset)
+  <<stf-special-macros>>
+  <<stf-rule-retrieval>>
+  <<stf-define-rule>>
+  <<stf-conversion-driver>>
+  <<stf-rules>>
+#+END_SRC
+

Some files were not shown because too many files changed in this diff