Created
December 9, 2016 15:28
-
-
Save scotthaleen/be984e8819e20a85d63bfe71067d9b3d to your computer and use it in GitHub Desktop.
fully qualify keys for a namespace
This file contains hidden or 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
| (defn ns-qualified-keys | |
| " | |
| takes a namespace and map of kv and converts it to namespace qualified keys | |
| (ns-qualified-keys 'foo.bar {:port 80}) | |
| ;;=> {:foo.bar/port 80} | |
| " | |
| [ns m] | |
| (into {} | |
| (for [[k v] m] | |
| [(keyword (str ns) (name k)) v]))) | |
| ;; usage | |
| (ns my.ns) | |
| (ns-qualified-keys *ns* {:foo 1 :bar 2}) | |
| ;;=> {:my.ns/foo 1, :my.ns/bar 2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment