minibuffer

How to swap elements in vectors in Emacs Lisp?

September 08, 2023
(setq vec [foo bar baz]) ;; [foo bar baz]
(aref vec 0) ;; foo
(aref vec 2) ;; baz
(cl-rotatef (aref vec 0) (aref vec 2))
vec ;; [baz bar foo]