(def class1 {:people '({:name "John" :age "25"} {:name "Harry" :age
"23"} {:name "Peter" :age "24"})}) or (def class1 {:people [{:name
"John" :age "25"} {:name "Harry" :age "23"} {:name "Peter" :age
"24"}]}) is probably what you want.

(mapv (juxt :name :age) (:people class1)) on either of those will give
you your result.

On 30 November 2016 at 10:34, Colin Yates <colin.ya...@gmail.com> wrote:
> Ah, I just realised people is _not_ a sequence of maps but the result
> of calling '{:name "John" :age "25"}' passing in the other two maps as
> arguments. You probably want a literal literal '({:name "John" :age
> "25"}.....) or a vector [{:name "John" :age "25"}...]
>
> On 30 November 2016 at 10:29, Colin Yates <colin.ya...@gmail.com> wrote:
>> (mapv (juxt :name :age) (:people class1)) should work
>>
>> On 30 November 2016 at 10:27, 'Rickesh Bedia' via Clojure
>> <clojure@googlegroups.com> wrote:
>>> I have a definition:
>>> (def class1 {:people ({:name "John" :age "25"}
>>>                                   {:name "Harry" :age "23"}
>>>                                   {:name "Peter" :age "24"})})
>>>
>>> The result I want is a vector that looks like
>>> [["John" "25"]
>>>  ["Harry" "23"]
>>>  ["Peter" "24"]]
>>>
>>> If I call (map (-> class1 :people) [:name :age])
>>> then I get the result ("Peter" "24"). Why do I only get the values from the
>>> last hashmap and not the others?
>>>
>>> If I then call (into [] (map (-> class1 :people) [:name :age]))
>>> then I get the result ["Peter" "24"]
>>>
>>> What I need to do is run the 'into' function again on the other two hashmaps
>>> and then put the 3 results into a vector but I don't know how to do this.
>>>
>>> Any help would be much appreciated
>>>
>>> --
>>> 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 posts from new members are moderated - please be patient with your
>>> first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to