Skip to content

Instantly share code, notes, and snippets.

@francoisdevlin
Created July 31, 2009 17:04
Show Gist options
  • Save francoisdevlin/159324 to your computer and use it in GitHub Desktop.
Save francoisdevlin/159324 to your computer and use it in GitHub Desktop.
(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