Wracking my brain this afternoon trying to figure this one out. I'm
fairly new to Clojure and Lisp in general. I have a data structure
that is a vector of maps and I want to get all the values for a
particular key out of all of the maps into another vector.
For example, let's say this is the
On Wed, Apr 20, 2011 at 4:24 AM, Dave kincaid.d...@gmail.com wrote:
The only way I could think of to do it is
(for [i (range (count(myvec)))] ((nth myvec i) key1))
Is there an easier way? It seems like there must be.
There is! (in fact there could be many ways)
(vec (map #(% key1) myvec))
If your keys were keywords, e.g. :key1, you could simply map them as
they are also functions:
(map :key1 ({:key1 value1} ...)
U
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that