I haven’t found much documentation or coding examples for doing manipulations on vectors of maps. For instance, if I have
(def student-grades
[{:name "Billy" :test1 74 :test2 93 :test3 89}
{:name "Miguel" :test1 57 :test2 79 :test3 85}
{:name "Sandy" :test1 86 :test2 97 :test3 99}
{:name "Dhruv" :test1 84 :test2 89 :test3 94}])
and I want to add or associate a new key value pair for the test averages, which functions should I read up on? Also if anyone knows of any reference/resources for vectors of maps in Clojure, please share! Thanks so much!
In this case, you want to map a function over the collection (which just happens to be a vector); for each element in the collection (which happens to be a map — unfortunate naming collision there), you want to generate a new map that has all the key-value pairs of the old map, plus a new key, let’s say :avg.
e.g.
ps you can use (doc fn-name) to get documentation on it; if you’re new to Clojure, I’d advise hanging out with the friendly folks on irc.freenode.net #clojure and read a book – my favorite is currently Programming Clojure, but I’m awaiting O’Reilly’s upcoming Clojure book with bated breath.