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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:31:46+00:00 2026-05-28T23:31:46+00:00

I have a clojure function that needs to push information into a map if

  • 0

I have a clojure function that needs to push information into a map if a particular condition is true, using that map as a parameter for another function.

I have the following, but it feels clumsy with the repeated calls to the bar function.

(defn foo ([opts]

  (if (= true (something))       
    (bar (into opts {:a b}))
    (bar opts)))

(def bar [opts])

So if (something) is true, we push extra options into the opts parameter before calling the bar function, otherwise we just pass it through.

  • 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-28T23:31:46+00:00Added an answer on May 28, 2026 at 11:31 pm

    First thing is that (= true (something)) can be replaced simply by (something) with no issues (unless you are actually trying to differentiate between a return value of true and a return value of, say, 1). If the options for the return value are true and false, (something) by itself will work fine. You can also use merge instead of into, which might be slightly clearer.

    You could try

    (bar (if (something)
           (merge opts {:a b})
           opts))
    

    This would work as well, though it involves calling merge unnecessarily when (something) is false, though with nil for the second argument, merge should return very quickly.

    (bar (merge opts
                (when (something)
                  {:a b})))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Clojure function that takes a sequence of numbers chops it into the
I'm using the HTML5 Web Database API and I have a function that checks
I have a clojure program that at some point executes a function called db-rebuild-files-table
My adventures in Java have lead me to look into Clojure, which then lead
I am writing a Clojure macro that accepts a description of a panel using
I have a JavaScript function that handles mouse button events. It must be able
I have a clojure function: (defn f [arg1 arg2] ...) I would like to
I'm learning clojure and have a very basic question: given that clojure has type
I have a jQuery plugin that needs to register a click event handler: $.fn.myPlugin
I need to write a function that splits records into separate files based on

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.