Refactor the shared variables copypasting
    
        | author | Steve Losh <steve@stevelosh.com> | 
    
        | date | Mon, 18 Apr 2016 15:38:02 +0000 | 
    
    
        | parents | e45304805b40 | 
    
        | children | d8dc03903456 | 
    
        | branches/tags | (none) | 
    
        | files | src/wam/compiler.lisp | 
Changes
    
--- a/src/wam/compiler.lisp	Mon Apr 18 15:29:53 2016 +0000
+++ b/src/wam/compiler.lisp	Mon Apr 18 15:38:02 2016 +0000
@@ -609,12 +609,13 @@
 (defun find-shared-variables (terms)
   "Return a list of all variables shared by two or more terms."
   (let* ((variables (remove-duplicates (tree-collect #'variable-p terms))))
-    (flet ((permanent-p (variable)
-             "Permanent variables are those contained in more than 1 term."
-             (> (count-if (curry #'tree-member-p variable)
-                          terms)
-                1)))
-      (remove-if-not #'permanent-p variables))))
+    (labels
+        ((count-uses (variable)
+           (count-if (curry #'tree-member-p variable)
+                     terms))
+         (shared-p (variable)
+           (> (count-uses variable) 1)))
+      (remove-if-not #'shared-p variables))))
 
 (defun find-permanent-variables (clause)
   "Return a list of all the 'permanent' variables in `clause`.