【发布时间】:2016-03-24 21:47:29
【问题描述】:
这周刚开始使用 Clojure,我的头撞到了墙上。虽然我知道 Clojure 中没有什么是可变的,但我通常不明白如何使用之前分配的数据更新原子键的值。
我正在努力解决的 2 个简化示例是...
(def test-db (atom
{:name "jessie" :points 4}))
(swap! test-db update :points (:points + 5))
(def another-test-db (atom
{:name "roger" :nums [1 2 3]}))
(swap! another-test-db update :nums (apply str :nums))
任何帮助将不胜感激!
【问题讨论】:
标签: clojure clojurescript