Re: The 'in' family

2010-12-15 Thread ninjudd
i completely agree about adding update to core. i've added it my utils library and i use it all the time. here's a slightly different implementation of update that takes a variable number of args (like update-in). (defn update "Update value in map where f is a function that takes the old valu

Re: The 'in' family

2010-12-14 Thread nickik
On Dec 15, 6:12 am, Mark Engelberg wrote: > One thing I've argued for in the past, but got no traction: > We have: > get-in, get > assoc-in, assoc > update-in, ? > Let's add update to go with update-in. update should really be in there. I always try to write update then i remember that I have to

Re: The 'in' family

2010-12-14 Thread javajosh
On Dec 14, 8:52 pm, ka wrote: > user=> (get-in m []) > {:a {:b {:c 10, :c1 20}, :b1 90}, :a1 100} This seems strange to me. I would expect Clojure to return nil, as there is no key in there that is nil. Assuming that an empty vector is the same as asking for a nil key, that is. (I suppose it ma

Re: The 'in' family

2010-12-14 Thread Ken Wesson
On Wed, Dec 15, 2010 at 12:12 AM, Mark Engelberg wrote: > One thing I've argued for in the past, but got no traction: > We have: > get-in, get > assoc-in, assoc > update-in, ? > Let's add update to go with update-in. Let's give them absolutely no excuse like "we don't have time to write the code

Re: The 'in' family

2010-12-14 Thread Mark Engelberg
One thing I've argued for in the past, but got no traction: We have: get-in, get assoc-in, assoc update-in, ? Let's add update to go with update-in. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

The 'in' family

2010-12-14 Thread ka
The functions get-in, assoc-in, update-in are really useful. Just wanted to share a thoughts. user=> (def m {:a {:b {:c 10 :c1 20} :b1 90} :a1 100}) #'user/m 1. Lets see the behavior of these functions in the corner case of empty keyseq: user=> (get-in m []) {:a {:b {:c 10, :c1 20}, :b1 90}, :a1