Created
July 31, 2009 17:04
-
-
Save francoisdevlin/159324 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
(defn apply-map | |
"This works like apply, gmabut for keyword arguments in a map." | |
[f & args] | |
(let [pos-args (butlast args) | |
a-map (last args) | |
applied-args (concat | |
(if pos-args pos-args []) | |
(cond | |
(nil? a-map) [] | |
(map? a-map) (reduce concat a-map) | |
true (vector a-map)))] | |
(apply f applied-args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment