How to append to a nested list in a Clojure atom? -
i want append value list in clojure atom:
(def thing (atom {:queue '()}))
i know when it's not atom, can this:
(concat '(1 2) '(3))
how can translate swap! command?
note: asked similar question involving maps: using swap merge (append to) nested map in clojure atom?
user=> (def thing (atom {:queue '()})) #'user/thing user=> (swap! thing update-in [:queue] concat (list 1)) {:queue (1)} user=> (swap! thing update-in [:queue] concat (list 2)) {:queue (1 2)} user=> (swap! thing update-in [:queue] concat (list 3)) {:queue (1 2 3)}
Comments
Post a Comment