Yup, you need to use the transient functions, e.g., assoc!, just as you would the persistent functions. This is nice since you can write your code in the persistent style, then if you need to make some performance tweaks, simply add some exclamation points; the structure of the code remains the same.
As for why you see what you're seeing, the assoc! does generally mutate the passed in map, thus you see some map entries. The rub is that assoc! is smart enough to choose the right implementation for the size; for small maps (0-8 entries) an array-map is used (and the {} literal is also an array-map). Once you assoc! the 9th element, the function instead returns a hashmap, thus no longer mutating the instance referenced by thm. On May 29, 2:41 pm, Jarkko Oranen <chous...@gmail.com> wrote: > On May 30, 12:32 am, Daniel Borchmann > > <daniel.borchm...@googlemail.com> wrote: > > The same happens if i goes up to 100, 1000, ... Is this a bug or is > > this a fundamental misconception of mine? > > You're using them wrong. Transients are not imperative data > structures. You need to capture the return value of assoc! and use > that as the new transient. -- 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