Refactor SUBST to use COND
authorStrigoides <Strigoides@gmail.com>
Fri, 26 Apr 2013 20:13:14 +0000 (08:13 +1200)
committerStrigoides <Strigoides@gmail.com>
Fri, 26 Apr 2013 20:13:14 +0000 (08:13 +1200)
src/list.lisp

index fd6b5d3..f1d5afb 100644 (file)
     tree))
 
 (defun subst (new old tree &key (key #'identity) (test #'eql))
-  (if (funcall test (funcall key tree) (funcall key old))
-    new
-    (if (consp tree)
-      (cons (subst new old (car tree) :key key :test test)
-            (subst new old (cdr tree) :key key :test test))
-      tree)))
+  (cond 
+    ((funcall test (funcall key tree) (funcall key old))
+     new) 
+    ((consp tree)
+     (cons (subst new old (car tree) :key key :test test)
+           (subst new old (cdr tree) :key key :test test))) 
+    (t tree)))