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 8653915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:39:26+00:00 2026-06-12T14:39:26+00:00

I have an atom, (def a (atom {:a <some-value>})) and it needs to be

  • 0

I have an atom,

(def a (atom {:a <some-value>}))

and it needs to be updated continuously, what would be the most memory efficient call in the long run…?

(swap! a assoc :a <next-value>)

or

(swap! a (fn [_] {:a <next-value>}))

Intuitively, based on the talks I have heard on persistent structures, I’m thinking that the second way would be a little slower but better in the long-run… but would like a second opinion.

  • 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-06-12T14:39:27+00:00Added an answer on June 12, 2026 at 2:39 pm
    1. The first form doesn’t work.
    2. Memory efficiency is irrelevant: how you get to the new value has no impact on the long-term amount of memory usage once the old value is thrown away.
    3. You appear to want reset!, not swap!.
    4. Consider why you’re updating an atom so often, especially if you don’t care about its previous value at all. You can usually accomplish something similar more easily with a purely functional approach, or at least with a swap! function that takes the old value into account.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At some point of my program I have an atom formed by what previously
I'm parsing an external Atom feed, some entries have a collection of namespaced children
I have been attempting to write some routines to read RSS and ATOM feeds
I have an Atom feed for my blog . I recently had some audio
I have a application built in Silverlight, which will run on a ATOM processor
I have a simple Atom 1.0 feed that I've generated, similar to the example
I have a ready RSS atom feed on my ASP.net site,but I want to
I have this code to create an ATOM feed Dim xmlResult As New StringBuilder
I have an SQL server on a server at home (which is an Atom
I have the following XML Document: <?xml version=\1.0\ encoding=\UTF-8\?> <atom:entry xmlns:atom=\http://www.w3.org/2005/Atom\ xmlns:apps=\http://schemas.google.com/apps/2006\ xmlns:gd=\http://schemas.google.com/g/2005\> <apps:property

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.