Created
April 8, 2013 22:57
-
-
Save spacebat/5341291 to your computer and use it in GitHub Desktop.
Insert an element before another in a list
This file contains hidden or 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
| (let ((data '((a 1 2 3)(c 5 6 7))) | |
| (insert '(b x y z))) | |
| (loop for prev on data | |
| for next on (cdr data) | |
| if (and next (eq (caar next) 'c)) | |
| do (let ((newcons (cons insert next))) | |
| (setcdr prev newcons))) | |
| data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment