Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Last active December 15, 2015 05:19
Show Gist options
  • Select an option

  • Save Wilfred/5208113 to your computer and use it in GitHub Desktop.

Select an option

Save Wilfred/5208113 to your computer and use it in GitHub Desktop.
Replace all occurrences of atom FROM with TO in an arbitrarily nested list.
(require 'dash)
(defun replace-nested-list (from to list)
"Replace all occurrences of atom FROM with TO in an arbitrarily nested LIST."
(--map
(cond
((consp it) (in-ns--replace-nested-list from to it))
((eq it from) to)
('t it))
list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment