I really needed an update-in! version that works on transients. I
couldn't find one so I just modified the original update-in core (just
replaced "assoc" "assoc!"):
(defn update-in!
"modified version of core/update-in that works on, and return
transients"
([m [k & ks] f & args]
(if ks
(assoc! m k (apply update-in! (get m k) ks f args))
(assoc! m k (apply f (get m k) args)))))
user=> (persistent!(update-in!(transient v) [0] reverse))
[(2 1) [3 4]]
BUT when using nested paths, it fails:
user=>(persistent!(update-in!(transient v) [0 0] inc))
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be
cast to clojure.lang.ITransientAssociative
Any idea how to solve this?
--
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