Guys, I really need your expertise here. I have lots of deeply nested vectors, which i need to manipulate frequently (thousands of times) What is the most effective way to do this ?
On Jan 17, 4:27 pm, Gabi <bugspy...@gmail.com> wrote: > Right. I thought that transient performing deep 'transientivity'. > Here is a fixed version. It takes a regular coll converts whatever it > can to transient and update the stuff. > The problem is that doing persistent!(assoc!(transient m)) on each > level probably misses the whole point of performance. > So while it work, it probably slower than the regular update-in. > I need a better solution. > > (defn update-in!! > "modified version of core/update-in that works on, and return > transiants" > ([m [k & ks] f & args] > (if ks > (persistent!(assoc! (transient m) k (apply update-in!! (get m k) > ks f args))) > (persistent!(assoc! (transient m) k (apply f (get m k) args)))))) > > On Jan 17, 3:57 pm, Chouser <chou...@gmail.com> wrote: > > > On Sun, Jan 17, 2010 at 8:25 AM, Gabi <bugspy...@gmail.com> wrote: > > > >> user=> (persistent!(update-in!(transient v) [0] reverse)) > > > > Forgot to mention that v in the example is defined to [[1 2] [3 4]] > > > So you've got a transient vector of persistent vectors of > > numbers. The problem is your update-in! then calls assoc! on > > each level, but of course assoc! on the inner persistent vector > > fails. > > > You either need to make the inner vectors transient (and then > > call persist! on them when you're done) or use assoc! only at the > > outer level. > > > --Chouserhttp://joyofclojure.com/
-- 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