|
@@ -1092,13 +1092,13 @@ This is the assembly of the ~#:larcs.manipulate~ package. It includes, in corre
|
|
|
<<am-expression-manipulation>>
|
|
|
#+END_SRC
|
|
|
|
|
|
-* TODO Manipulators for Addition
|
|
|
+* WORKING Manipulators for Addition [0/1]
|
|
|
:PROPERTIES:
|
|
|
:CREATED: <2016-04-30 Sat 23:08>
|
|
|
:ID: b794486c-e493-408f-b80c-a440edae1bc8
|
|
|
:END:
|
|
|
|
|
|
-Foo
|
|
|
+To accomplish the goal of providing a system that can manipulate any and all proper algebraic expressions, one of the most basic operations of such is addition. This provides a set of manipulators acting upon proper additive expressions. It declares itself to be a part of the ~#:larcs.manipulate~ package; defines an operation for addition, called ~add~, taking 2 arguments with a short-name of ~+~. It then includes the various manipulators that are defined for addition.
|
|
|
|
|
|
#+Caption: Addition Manipulator
|
|
|
#+Name: am-addition-manipulator
|
|
@@ -1107,72 +1107,86 @@ Foo
|
|
|
|
|
|
(define-operation add 2 +)
|
|
|
|
|
|
+ <<addition-manipulators-for-numerics>>
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
+** TODO Numerics
|
|
|
+:PROPERTIES:
|
|
|
+:CREATED: <2016-09-23 Fri 16:38>
|
|
|
+:ID: 3d9c9da7-ab93-48e3-a340-07d4d80f7f47
|
|
|
+:END:
|
|
|
+
|
|
|
+Find Outer Otter
|
|
|
+
|
|
|
+#+Caption: Addition Manipulators for Numerics
|
|
|
+#+Name: addition-manipulators-for-numerics
|
|
|
+#+BEGIN_SRC lisp
|
|
|
(define-add-manipulator (numeric numeric)
|
|
|
- (+ expression-a expression-b))
|
|
|
+ (+ expression-a expression-b))
|
|
|
|
|
|
(define-add-manipulator (numeric additive)
|
|
|
- (let ((total expression-a)
|
|
|
- (remainder (rest expression-b))
|
|
|
- (non-numeric '()))
|
|
|
- (dolist (element remainder)
|
|
|
- (if (classified-as-p element 'numeric)
|
|
|
- (incf total element)
|
|
|
- (push element non-numeric)))
|
|
|
- (cond
|
|
|
- ((null non-numeric)
|
|
|
- total)
|
|
|
- ((= 0 total)
|
|
|
- `(+ ,@non-numeric))
|
|
|
- (t
|
|
|
- `(+ ,total ,@non-numeric)))))
|
|
|
+ (let ((total expression-a)
|
|
|
+ (remainder (rest expression-b))
|
|
|
+ (non-numeric '()))
|
|
|
+ (dolist (element remainder)
|
|
|
+ (if (classified-as-p element 'numeric)
|
|
|
+ (incf total element)
|
|
|
+ (push element non-numeric)))
|
|
|
+ (cond
|
|
|
+ ((null non-numeric)
|
|
|
+ total)
|
|
|
+ ((= 0 total)
|
|
|
+ `(+ ,@non-numeric))
|
|
|
+ (t
|
|
|
+ `(+ ,total ,@non-numeric)))))
|
|
|
|
|
|
(define-add-manipulator (additive additive)
|
|
|
- (let ((total 0)
|
|
|
- (elements (append (rest expression-a)
|
|
|
- (rest expression-b)))
|
|
|
- (non-numeric '()))
|
|
|
- (dolist (element elements)
|
|
|
- (if (classified-as-p element 'numeric)
|
|
|
- (incf total element)
|
|
|
- (push element non-numeric)))
|
|
|
- (cond
|
|
|
- ((null non-numeric)
|
|
|
- total)
|
|
|
- ((= 0 total)
|
|
|
- `(+ ,@non-numeric))
|
|
|
- (t
|
|
|
- `(+ ,total ,@non-numeric)))))
|
|
|
+ (let ((total 0)
|
|
|
+ (elements (append (rest expression-a)
|
|
|
+ (rest expression-b)))
|
|
|
+ (non-numeric '()))
|
|
|
+ (dolist (element elements)
|
|
|
+ (if (classified-as-p element 'numeric)
|
|
|
+ (incf total element)
|
|
|
+ (push element non-numeric)))
|
|
|
+ (cond
|
|
|
+ ((null non-numeric)
|
|
|
+ total)
|
|
|
+ ((= 0 total)
|
|
|
+ `(+ ,@non-numeric))
|
|
|
+ (t
|
|
|
+ `(+ ,total ,@non-numeric)))))
|
|
|
|
|
|
(define-add-manipulator (numeric subtractive)
|
|
|
- (let ((total expression-a)
|
|
|
- (the-other (rest expression-b))
|
|
|
- (non-numeric '()))
|
|
|
- (dolist (element the-other)
|
|
|
- (if (classified-as-p element 'numeric)
|
|
|
- (decf total element)
|
|
|
- (push element non-numeric)))
|
|
|
- (cond
|
|
|
- ((null non-numeric)
|
|
|
- total)
|
|
|
- ((= 0 total)
|
|
|
- `(+ ,@non-numeric))
|
|
|
- (t
|
|
|
- `(+ ,total (-,@non-numeric))))))
|
|
|
+ (let ((total expression-a)
|
|
|
+ (the-other (rest expression-b))
|
|
|
+ (non-numeric '()))
|
|
|
+ (dolist (element the-other)
|
|
|
+ (if (classified-as-p element 'numeric)
|
|
|
+ (decf total element)
|
|
|
+ (push element non-numeric)))
|
|
|
+ (cond
|
|
|
+ ((null non-numeric)
|
|
|
+ total)
|
|
|
+ ((= 0 total)
|
|
|
+ `(+ ,@non-numeric))
|
|
|
+ (t
|
|
|
+ `(+ ,total (-,@non-numeric))))))
|
|
|
|
|
|
(define-add-manipulator (numeric polynomial-term)
|
|
|
- `(+ ,expression-a ,expression-b))
|
|
|
+ `(+ ,expression-a ,expression-b))
|
|
|
|
|
|
(define-add-manipulator (polynomial-term polynomial-term)
|
|
|
- (if (single-term-combinable-p expression-a expression-b)
|
|
|
- (let ((new-coefficient (+ (coefficient expression-a)
|
|
|
- (coefficient expression-b)))
|
|
|
- (variable (term-variable expression-a))
|
|
|
- (power (get-power expression-a)))
|
|
|
- `(* ,new-coefficient (expt ,variable ,power)))
|
|
|
- `(+ ,expression-a ,expression-b)))
|
|
|
+ (if (single-term-combinable-p expression-a expression-b)
|
|
|
+ (let ((new-coefficient (+ (coefficient expression-a)
|
|
|
+ (coefficient expression-b)))
|
|
|
+ (variable (term-variable expression-a))
|
|
|
+ (power (get-power expression-a)))
|
|
|
+ `(* ,new-coefficient (expt ,variable ,power)))
|
|
|
+ `(+ ,expression-a ,expression-b)))
|
|
|
|
|
|
(define-add-manipulator (* numeric)
|
|
|
- (add expression-b expression-a))
|
|
|
+ (add expression-b expression-a))
|
|
|
#+END_SRC
|
|
|
|
|
|
* TODO Manipulators for Subtraction
|