如何附加到Clojure原子中的嵌套列表?

szx*_*zxk 4 clojure

我想将值附加到Clojure原子中的列表:

(def thing (atom {:queue '()}))
Run Code Online (Sandbox Code Playgroud)

我知道当它不是原子时,我可以这样做:

(concat '(1 2) '(3))
Run Code Online (Sandbox Code Playgroud)

我怎样才能将其翻译成交换!命令?

注意:我问了一个涉及地图的类似问题:在Clojure原子中使用swap到MERGE(追加)嵌套地图?

Ale*_*ler 8

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)}
Run Code Online (Sandbox Code Playgroud)