Ver Fonte

Added a variable collector

Samuel W. Flint há 9 anos atrás
pai
commit
e37a6b377f
1 ficheiros alterados com 24 adições e 0 exclusões
  1. 24 0
      manipulation.org

+ 24 - 0
manipulation.org

@@ -474,6 +474,28 @@ The storage of classifications is simple, they are stored as an alist in the for
   (defvar *classifications* '())
 #+END_SRC
 
+* WORKING Collect Variables
+:PROPERTIES:
+:CREATED:  <2016-05-20 Fri 15:15>
+:ID:       6333322c-e12f-4ef6-8394-2fe219a72836
+:END:
+
+#+Caption: Collect Variables
+#+Name: collect-variables
+#+BEGIN_SRC lisp
+  (defun collect-variables (expression)
+    (let ((variables '()))
+      (flet ((merge-variables (variable)
+               (pushnew variable variables)))
+        (classification-case expression
+                             (variable (merge-variables expression))
+                             (non-atomic (map 'list #'(lambda (expr)
+                                                        (loop for var in (collect-variables expr)
+                                                           do (merge-variables var)))
+                                              (rest expression)))))
+      (reverse variables)))
+#+END_SRC
+
 * WORKING Term Collection                                          :noexport:
 :PROPERTIES:
 :CREATED:  <2016-04-30 Sat 22:59>
@@ -913,6 +935,8 @@ This assembles and packages the algebraic manipulation system into a single file
 
   <<determine-expression-type>>
 
+  <<collect-variables>>
+
   <<polynomial-related-functions>>
 
   <<expression-manipulation>>