From: David Vazquez Date: Mon, 17 Dec 2012 00:18:39 +0000 (+0000) Subject: !reduce X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=de05b1e2630ab474d4d32f163a82578bf6351c4e;p=jscl.git !reduce --- diff --git a/lispstrack.lisp b/lispstrack.lisp index 8a78bf5..6d49443 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -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) diff --git a/test.lisp b/test.lisp index eff3ac4..d224c5d 100644 --- a/test.lisp +++ b/test.lisp @@ -36,12 +36,6 @@ (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