assoc-in "works" for vectors in the sense that both vectors and maps implement ILookup (get) and IAssoc (assoc). assoc-in can navigate any collection that understands "get" (including sets!), and add to any collection that understands "assoc".
However, assoc-in will *always* create *maps* when it encounters missing keys. This is unlikely to be what you want most of the time when working with a vector structure. Examples: (assoc-in [:a [:b [:c :d] :e]] [1 1 1] :f) ;=> [:a [:b [:c :f] :e]] (assoc-in [] [0] :a) ;=> [:a] (assoc-in [] [1] :a) ;IndexOutOfBoundsException clojure.lang.PersistentVector.assocN (PersistentVector.java:183) (assoc-in [] [0 0] :a) ;=> [{0 :a}] (assoc-in [] [0 0 0] :a) ;=> [{0 {0 :a}}] (assoc-in [] [0 0 1] :a) ;=> [{0 {1 :a}}] On Thursday, August 6, 2015 at 7:29:04 AM UTC-5, Carl Smotricz wrote: > > Dunno if this is the correct place and way to suggest a correction: > > Someone just mentioned to me that (assoc-in) seems to only work for maps, > as the Cheat Sheet section on vectors doesn't mention it. I was able to > show him otherwise, but maybe this is something the CS should pick up? > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.