Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Created November 25, 2014 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustingetz/dcf0498d1cc48de26bae to your computer and use it in GitHub Desktop.
Save dustingetz/dcf0498d1cc48de26bae to your computer and use it in GitHub Desktop.
(ns streaker-service.util)
(defn deep-merge
"Recursively merges maps. If vals are not maps, the last value wins.
(from https://groups.google.com/forum/#!topic/clojure/UdFLYjLvNRs)"
[& vals]
(if (every? map? vals)
(apply merge-with deep-merge vals)
(last vals)))
(comment
(deep-merge {:a "a"
:b {:bb "bb"}}
{:a 10
:b {:bc "bc"}
:c 20})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment