From: David Vazquez Date: Mon, 17 Dec 2012 00:14:58 +0000 (+0000) Subject: !reduce X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=1eaefd228c8010e2cb9cb73ea62dfeec5ab19053;p=jscl.git !reduce --- diff --git a/test.lisp b/test.lisp index 2f4dd35..eff3ac4 100644 --- a/test.lisp +++ b/test.lisp @@ -12,6 +12,7 @@ (%compile-defun ',name)) (fsetq ,name (lambda ,args ,@body)))) +(defun + (x y) (+ x y)) (defun 1+ (x) (+ x 1)) (defun 1- (x) (- x 1)) @@ -35,6 +36,13 @@ (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 (lambda (x y) x)