Skip to content

Instantly share code, notes, and snippets.

@pd
Created December 27, 2008 04:35
Show Gist options
  • Select an option

  • Save pd/40189 to your computer and use it in GitHub Desktop.

Select an option

Save pd/40189 to your computer and use it in GitHub Desktop.
(defun reverse-alist (alist)
(mapcar
'(lambda (cell) ((cdr cell) . (car cell)))
alist))
(reverse-alist '(("a" . "b")
("c" . "d")))
; => '(("b" . "a")
; ("c" . "d"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment