Noob clojure question. I have a list of items and I want to append a subitem to one of them. They're currently unkeyed because I care about the order and it seemed more intuitive that way.
(def items [{ :id 1 :subitems [] } { :id 2 :subitems [] }]) So let's say I want a new list where the second one has two a new subitem would a map be appropriate, but only operate on the matching id? ; item-id and subitem in scope (defn add-subitem-if-id-matches [item] (if (= (item :id) ; return new item with additional subitem ; return unmodified item ) and run that through a map? It seems to work, but I'm not sure if that's the best way to go about doing it. (map add-subitem-if-id-matches items) ; returns new list of items where subitem has been added to one of them. A more simple example. '( '(1, "hello") '(2, "goodbye") ) Would I run something like this through a map if I wanted to only map/modify certain elements like if the first element was 2 or even or something? '( '(1, "hello") '(2, "ack") ) -- 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.