On Sep 18, 10:44 am, Chas Emerick <[email protected]> wrote:
> On Sep 18, 2011, at 1:10 PM, Stuart Halloway wrote:
>
> >> The other example that immediately leaps to mind is that the family of
> >> get-in, get, and update-in implies the existence of update. It is rather
> >> startling to me that update does not exist in the core.
>
> > This is a good question. I don't know why I never noticed its absence. Have
> > other people missed this?
>
> What would an `update` function do? update-in is for swapping out a value
> accessible via a particular "chain" of keys. Dropping the -in suffix implies
> to me that `update` would operate on the top-level data structure, but that's
> what assoc/dissoc/conj do already.
Agreed that this is why it doesn't exist. Personally I wouldn't mind
having update (and have asked for it before), but you have to decide
what to use the varargs for: extra arguments to the update function,
or a set of top-level keys? That is, given m={:a 1, :b 2}:
(update m :a :b inc) => {:a 2, :b 3}
--OR--
(update m :a + 2) => {:a 3, :b 2}
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en