mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-15 15:21:03 -08:00
Fixed optimization of MAPL and MAPC: output value was wrong.
This commit is contained in:
parent
713258df56
commit
984631d80f
1 changed files with 12 additions and 2 deletions
|
|
@ -31,7 +31,9 @@
|
|||
(args (cddr whole))
|
||||
iterators for-statements
|
||||
(in-or-on :IN)
|
||||
(do-or-collect :COLLECT))
|
||||
(do-or-collect :COLLECT)
|
||||
(list-1-form nil)
|
||||
(finally-form nil))
|
||||
(case which
|
||||
(MAPCAR)
|
||||
(MAPLIST (setf in-or-on :ON))
|
||||
|
|
@ -39,11 +41,19 @@
|
|||
(MAPL (setf in-or-on :ON do-or-collect :DO))
|
||||
(MAPCAN (setf do-or-collect 'NCONC))
|
||||
(MAPCON (setf in-or-on :ON do-or-collect 'NCONC)))
|
||||
(when (eq do-or-collect :DO)
|
||||
(let ((var (gensym)))
|
||||
(setf list-1-form `(with ,var = ,(first args))
|
||||
args (list* var (rest args))
|
||||
finally-form `(finally (return ,var)))))
|
||||
(loop for arg in (reverse args)
|
||||
do (let ((var (gensym)))
|
||||
(setf iterators (cons var iterators)
|
||||
for-statements (list* :for var in-or-on arg for-statements))))
|
||||
`(loop ,@for-statements ,do-or-collect (funcall ,function ,@iterators)))))
|
||||
`(loop ,@list-1-form
|
||||
,@for-statements
|
||||
,do-or-collect (funcall ,function ,@iterators)
|
||||
,@finally-form))))
|
||||
|
||||
(define-compiler-macro mapcar (&whole whole &rest r)
|
||||
(expand-mapcar whole))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue