(defn apply-keys [f ks]
(zipmap ks (map f ks)))
Trivial to write, but it can be quite useful. For example:
(defn whatever [arg]
(let [some-list (make-list-from arg)
mapped (map myfunc some-list)]
(zipmap some-list mapped)))
compared to
(defn whatever [arg]
(apply-keys myfunc (make-list-from arg)))
I was working on my project and found myself doing this fairly often;
I searched high and low in clojure.core and clojure.contrib but
couldn't find anything similar. This amazed me, because it seems so
common and generic that I assumed clojure would do it for me. If this
isn't already in a standard library, I'd like to see it added. I'm
happy to give it away to someone who maintains a package that would
"fit" this function, or if someone wants to explain to me how to add
my own package I'm willing to do that.
Does this seem useful to anyone else?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en