!reduce
authorDavid Vazquez <davazp@gmail.com>
Mon, 17 Dec 2012 00:18:39 +0000 (00:18 +0000)
committerDavid Vazquez <davazp@gmail.com>
Mon, 17 Dec 2012 00:18:39 +0000 (00:18 +0000)
lispstrack.lisp
test.lisp

index 8a78bf5..6d49443 100644 (file)
@@ -1,3 +1,11 @@
+
+(defun !reduce (func list initial)
+  (if (null list)
+      initial
+      (!reduce func
+               (cdr list)
+               (funcall func initial (car list)))))
+
 ;;; Utils
 
 #+common-lisp
@@ -11,9 +19,9 @@
 
 ;;; simplify me, please
 (defun concat (&rest strs)
-  (reduce (lambda (s1 s2) (concatenate 'string s1 s2))
-          strs
-          :initial-value ""))
+  (!reduce (lambda (s1 s2) (concatenate 'string s1 s2))
+           strs
+           ""))
 
 ;;; Concatenate a list of strings, with a separator
 (defun join (list separator)
index eff3ac4..d224c5d 100644 (file)
--- a/test.lisp
+++ b/test.lisp
       (cons (funcall func (car list))
             (mapcar func (cdr list)))))
 
-(defun !reduce (func list initial)
-  (if (null list)
-      initial
-      (!reduce func
-               (cdr list)
-               (funcall func (car list) initial))))
 
 ;;; Tests