Hi,

Say I have a map like this:

    (def m {:qs [{:nums [3 1 2]} {:nums [7 4]}]})

I want to transform each number with a function (say, `inc`). I imagine 
something like this:

    (update-in m [:qs * :cell-fns] #(map inc %))  
    ; or 
    (update-in m [:qs * :cell-fns *] inc)  


But of course you can't write that.  The following code works, but I don't 
like reading it:

    (update m :qs   
        (fn [qs]
          (mapv
            (fn [q] 
              (update q :nums #(mapv inc %)))
            qs)))
    => {:qs [{:nums [4 2 3]} {:nums [8 5]}]}

Is there an idiomatic way to do this, that looks more like the shorter 
`update-in` idea?

Rob



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to