Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:57:36+00:00 2026-05-24T13:57:36+00:00

I haven’t found much documentation or coding examples for doing manipulations on vectors of

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:57:37+00:00Added an answer on May 24, 2026 at 1:57 pm

    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.

    (into [] ; optional -- places the answer into another vector
      (map   ; apply the given function to every element in the collection
        (fn [sg] ; the function takes a student-grade
          (assoc sg ; and with this student-grade, creates a new mapping
            :avg    ; with an added key called :avg
            (/ (+ (:test1 sg) (:test2 sg) (:test3 sg)) 3.0)))
        student-grades  ; and the function is applied to your student-grades vector
    ))
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't found any documentation on this or seen this done before, but is
I haven't worked with SQL Reporting much, however I have been trying to get
Haven't done as much of Javascript as I should have done. I am trying
haven't used regex replaces much and am not sure if how I have done
Haven't seen many Geneva related questions yet, I have posted this question in the
I haven't seen this question anywhere else, I hope someone can help. I have
Haven't seen anything, but I have seen that you can create albums in the
Haven't found what i'm looking for so far. I want to redirect all my
I haven't been able to find documentation that talk about how create.js.erb and destroy.js.erb
I haven't used the Zend Router much yet so not sure how difficult or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.