RosettaCodeData/Task/Generic-swap/Emacs-Lisp/generic-swap-3.el
2026-04-30 12:34:36 -04:00

8 lines
159 B
EmacsLisp

(require 'cl-lib)
(defmacro swap (a b)
`(cl-psetf ,a ,b
,b ,a))
(setq lst (list 123 456))
(swap (car lst) (cadr lst))
;; now lst is '(456 123)