Created
September 7, 2015 07:40
-
-
Save xuchunyang/abee057c0dddc5bccd0d to your computer and use it in GitHub Desktop.
Swap values of variables and Swap car and cdr of cons cell in Emacs Lisp
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 ((a 1) (b 2)) | |
(setq a (prog1 b (setq b a))) | |
(list a b)) | |
;; => (2 1) | |
(let ((con '(1 . 2))) | |
(setcar con (prog1 (cdr con) | |
(setcdr con (car con)))) | |
con) | |
;; => (2 . 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment