HCoop
/
clinton
/
parenscript.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
467e94f
)
Fixed 'flatten' to correctly handle lists with non-nil cdr (ie '(1 . 2)).
author
Vladimir Sedach
<vsedach@gmail.com>
Mon, 8 Jun 2009 04:35:05 +0000
(22:35 -0600)
committer
Vladimir Sedach
<vsedach@gmail.com>
Mon, 8 Jun 2009 04:35:05 +0000
(22:35 -0600)
Thanks to Scott Bell for the bug report.
http://common-lisp.net/pipermail/parenscript-devel/2009-June/000528.html
src/utils.lisp
patch
|
blob
|
blame
|
history
diff --git
a/src/utils.lisp
b/src/utils.lisp
index
de77d42
..
9047abb
100644
(file)
--- a/
src/utils.lisp
+++ b/
src/utils.lisp
@@
-99,7
+99,7
@@
SOMEGLOBAL."
,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
,@body)))))
-(defun flatten (x)
- (
if (atom x
)
-
(list x
)
-
(mapcan #'flatten x
)))
+(defun flatten (x
&optional acc
)
+ (
cond ((null x) acc
)
+
((atom x) (cons x acc)
)
+
(t (flatten (car x) (flatten (cdr x) acc))
)))