Parcourir la source

Updated the classify function, should be a bit more efficient

Samuel W. Flint il y a 9 ans
Parent
commit
3bd31622ec
1 fichiers modifiés avec 8 ajouts et 8 suppressions
  1. 8 8
      manipulation.org

+ 8 - 8
manipulation.org

@@ -133,14 +133,14 @@ To completely classify an expression, the ~*classifications*~ alist is mapped ov
 #+Name: classify-expression
 #+BEGIN_SRC lisp
   (defun classify (expression)
-    (remove-if #'null
-               (map 'list #'(lambda (name-and-checker)
-                              (let ((name (car name-and-checker))
-                                    (checker (cdr name-and-checker)))
-                                (if (funcall checker expression)
-                                    name
-                                    nil)))
-                    ,*classifications*)))
+    (let ((classifications '()))
+      (dolist (possible
+                ,*classifications*
+               (reverse classifications))
+        (let ((name (car possible))
+              (checker (cdr possible)))
+          (when (funcall checker expression)
+            (push name classifications))))))
 #+END_SRC
 
 ** WORKING Classifications [6/13]