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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:59:02+00:00 2026-06-06T22:59:02+00:00

Is there a jQuery type function to solve the problem of walking through nested

  • 0

Is there a jQuery type function to solve the problem of walking through nested maps?

for example, if i have a configuration that looks like this:

  (def fig
    {:config
      {:example
        {:a "a"
         :b "b"
         :c "c"}
       :more
        {:a "a"
         :b "b"
         :c "c"}}})

I still haven’t figured out a great way to manipulate nested persistent data structures with assoc and dissoc. However, if there was a jquery style way to manipulate maps, then I can write code like this:

  (->  fig
    ($ [:config :example :a] #(str % "a"))
    ($ [:config :b] #(str % "b")))

  Giving this output:

  {:config
    {:example
      {:a "aa"
       :b "bb"
       :c "c"}
     :more
      {:a "a"
       :b "bb"
       :c "c"}}}

And something like this for selectors:

($ fig [:config :example :a])
  ;=> "a"

($ fig [:config :b])
  ;=> {[:config :example :b] "b", 
  ;    [:config :more :b] "b"}

So in essence, I’m looking for an implementation of jayq for manipulation of clojure objects instead of html doms.

Thanks in advance!

  • 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-06T22:59:05+00:00Added an answer on June 6, 2026 at 10:59 pm

    First of all, you should check out Enlive.

    Otherwise: if you want to do what jQuery does (of course very simplified) – as opposed to just calling update-in:

    Select:

    (defn clj-query-select [obj path]
      (if (empty? path)
        (list obj)
        (when (map? obj)
          (apply concat
            (remove nil? 
              (for [[key value] obj]
                (clj-query-select
                  value 
                  (if (= key (first path)) (rest path) path))))))))
    

    For call:

    (clj-query-select {:a {:b 1} :b 2} [:b])
    

    it should yield:

    (1 2)
    

    Update/replace:

    (defn clj-query-update [obj path fn]
      (if (empty? path)
        (fn obj)
        (if (map? obj)
          (into obj
            (remove nil?
              (for [[key value] obj]
                (let [res (clj-query-update 
                            value 
                            (if (= key (first path)) (rest path) path)
                            fn)]
              (when (not= res value) [key res])))))
          obj)))
    

    For call:

    (clj-query-update {:c {:a {:b 1} :b 2}} [:c :b] #(* % 2))
    

    it should yield:

    {:c {:a {:b 2} :b 4}}
    

    I didn’t test it thoroughly though.

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

Sidebar

Related Questions

I have a problem that I have not managed to solve. I developed a
I'm working on a jQuery lightbox type plugin that needs to function for mobile
How can i achieve that I get jQuery-Intellisense in the following code example? function
In jQuery there is a cool function called .parents('xx') that enables me to start
Is there a jQuery plugin or effect that will create an overlay/lightbox effect around
Are there any jQuery sliders with a loading bar? I have seen them on
Is there a jQuery project out there, that create on of these Password-strength-meters right
Is there a jquery plugin that when you hover over an icon etc. it
Is there a jQuery plugin or javascript library that supports a genie animation effect
I am using : function ajax(u,s,t) { jQuery.ajax({type: POST, url: u, data: query, success:

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.