Created
June 20, 2013 14:50
-
-
Save vapniks/5823399 to your computer and use it in GitHub Desktop.
A mapping function that allows splicing lists into the result. If fun returns a list whose first element is @ the following elements will be spliced into the list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun mapcar@ (fun seq) | |
(let (result) | |
(loop for elem in (reverse seq) | |
for newelem = (funcall fun elem) | |
if (and (listp newelem) | |
(eq (car newelem) '@)) | |
do (loop for newelem2 in (cdr newelem) | |
do (setq result (cons newelem2 result))) | |
else do (setq result (cons newelem result))) | |
result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually forget it. Just realized it's probably easier to do it directly with a loop.