Created
May 31, 2011 04:53
-
-
Save amalloy/999885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user> (let [m {:text "foo" :user {:name "alan" :handle "alanmalloy"}}, | |
mappings [[:data :text] [:username :user :name]]] | |
(into {} | |
(for [[to & from] mappings] | |
[to (get-in m from)]))) | |
{:data "foo", :username "alan"} | |
user> (let [m {:text "foo" :user {:name "alan" :handle "alanmalloy"}}] | |
;; assume the above was gotten externally | |
(let [{{username :name} :user, data :text} m] | |
[username data])) | |
["alan" "foo"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment