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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:48:51+00:00 2026-06-12T12:48:51+00:00

Given a map {:a 1 :b [2,3]} , is there a built-in function which

  • 0

Given a map {:a 1 :b [2,3]}, is there a built-in function which would return the sequence (:a 1 :b [2,3]).

The use case is applying an options map to a function which does map-destructured binding on the remainder of an argument list. Here’s an example of this in core.cache. Here’s a contrived example to illustrate:

(defn make-car [& {:as options}] (assoc options :car true))
(make-car :color "red" :speed "fast")
; => {:car true, :speed "fast", :color "red"}

Now if we want to manage the options separately and apply them to the function, we have a problem:

(def options {:color "red" :speed "fast"})
(apply make-car options)
; => {:car true, [:speed "fast"] [:color "red"]}

…because of course the seq of a map is a sequence of its key-value pairs. This is the best I’ve come up with:

(apply make-car (interleave (keys options) (vals options)))
; => {:car true, :speed "fast", :color "red"}

This is pretty awful. I know I could just make my own function to do this, but I’m surprised I haven’t found something built-in. If there isn’t something built-in, then I’d probably want to avoid destructuring argument lists like this in library code.

  • 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-12T12:48:52+00:00Added an answer on June 12, 2026 at 12:48 pm

    How about this:

    (reduce concat {:a 1 :b [2,3]})
    (:a 1 :b [2 3])
    

    Update based on the comment from amalloy.
    Apply is more efficient (at least in 1.4), and achieves the same result!

    (apply concat {:a 1 :b [2,3]})
    (:a 1 :b [2 3])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Further to my other question given the following classes and fluent map, is there
Given the following two code options, is there any performance benefit (over a very
Given this: [ (A,A122); (A,A123); (B,B122); (B,B123); (C,C122); ] Is there a standard function
I have built two XML files that map the content of a given folder:
I know there's the built-in _stats function that gives you sum, count, min, max,
Given a simple namespaced route map.namespace :api do |api| api.resources :genres end how can
Given the following example (using JUnit with Hamcrest matchers): Map<String, Class<? extends Serializable>> expected
I want to draw an area from given points on a map using the
I've got 2 GeoPoints given to show them on the map with markers. How
I found the following statement: Map is an object that stores key/volume pairs. Given

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.