Proposal: mapply
gfredericks opened this issue · comments
Positional map arguments are a pain to work with programmatically.
(defn mapply
"Takes a function, optional initial args, and a map, and applies
the keys/vals of the map as positional varargs to the function."
([f m] (apply f (apply concat m)))
([f & args]
(apply f (concat (butlast args) (apply concat (last args))))))
At Prismatic we don't use the & map
destructuring (largely for this reason), and prefer to just pass an explicit map of options. That said, from prior experience with such functions I can see this being useful for those who do use them. If you want to provide a PR with tests, we'd be happy to accept it. Thanks!
Thanks!
I also try to avoid using & map
, but it still pops up in a number of libraries (not to mention clojure.core
), and is apparently actively encouraged.
Makes sense -- interesting, thanks for the pointer.
On Wed, Apr 2, 2014 at 4:29 AM, Gary Fredericks notifications@github.comwrote:
Thanks!
I also try to avoid using & map, but it still pops up in a number of
libraries (not to mention clojure.core), and is apparently actively
encouragedhttp://dev.clojure.org/display/community/Library+Coding+Standards
.Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-39319355
.