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

  • Home
  • SEARCH
  • 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 6475681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:44:03+00:00 2026-05-25T06:44:03+00:00

Still working through Programming Collective Intelligence and using Clojure to write the code. I’ve

  • 0

Still working through Programming Collective Intelligence and using Clojure to write the code. I’ve got it working, but some parts are really ugly, so I thought I’d ask some of the experts around here to help clean it up.

Let’s suppose I have a map that looks like this (bound to “recs“):

{"Superman Returns" 3.902419556891574, "Lady in the Water" 2.8325499182641614, 
"Snakes on a Plane" 3.7059737842895792, "The Night Listener" 3.3477895267131017,
"You, Me and Dupree" 2.651006036204627, "Just My Luck" 2.5309807037655645}

and I want to remove those items with keys that are also in the map (bound to “mymovies“):

{"Snakes on a Plane" 4.5, "You, Me and Dupree" 1.0, "Superman Returns" 4.0}

so that I get the map:

{"Lady in the Water" 2.8325499182641614, "The Night Listener" 3.3477895267131017,
"Just My Luck" 2.5309807037655645}

the code that I managed to get to do this looks like:

(apply merge (map #(hash-map (first %) (second %))
              (remove #(contains? mymovies (first %))
                      recs)))

That seems pretty ugly to me. It doesn’t seem like it should be necessary to create a map from the value I get back from “remove”. Is there a cleaner way to do this?

UPDATE: Joost’s answer below sparked another idea. If I turn the keys of the two maps into sets I can use select-keys like this:

(select-keys recs (difference (set (keys recs))
                              (set (keys mymovies))))

Joost, thanks for turning me on to select-keys. I didn’t know about that function before. Now to go rewrite several other sections with this new found knowledge!

  • 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-25T06:44:03+00:00Added an answer on May 25, 2026 at 6:44 am
    (apply dissoc recs (keys mymovies))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still working my way through some pretty basic Actionscript programming (in Flex), and
Update: We are still using XP at work and I got my solution working,
I'm still working on a particular RDF file, but seems that something is not
I still very new using Subversion. Is it possible to have a working copy
I'm working through the Key Value Coding chapter in Programming for Mac OS X.
If you are working in PHP (or I guess any programming language) and using
I aware that this will be a less programming question, but still... How can
I'm still learning my way through iOS development and working with Core Data and
I'm a novice in PHP & MySQL coding and still working my way through
I'm reading through the Professional iPhone Programming with MonoTouch and .NET/C# book, but I'm

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.