projects
/
jscl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6c810eb
)
Iterative MAPCAR
author
David Vázquez
<davazp@gmail.com>
Fri, 8 Feb 2013 22:47:13 +0000
(23:47 +0100)
committer
David Vázquez
<davazp@gmail.com>
Fri, 8 Feb 2013 22:47:13 +0000
(23:47 +0100)
ecmalisp.lisp
patch
|
blob
|
history
diff --git
a/ecmalisp.lisp
b/ecmalisp.lisp
index
9951c03
..
cdf33d0
100644
(file)
--- a/
ecmalisp.lisp
+++ b/
ecmalisp.lisp
@@
-350,10
+350,14
@@
(concat-two s1 s2))
(defun mapcar (func list)
- (if (null list)
- '()
- (cons (funcall func (car list))
- (mapcar func (cdr list)))))
+ (let* ((head (cons 'sentinel nil))
+ (tail head))
+ (while (not (null list))
+ (let ((new (cons (funcall func (car list)) nil)))
+ (rplacd tail new)
+ (setq tail new
+ list (cdr list))))
+ (cdr head)))
(defun identity (x) x)