【发布时间】:2022-10-17 21:13:04
【问题描述】:
我是 clojure 的新手,如果不像其他语言那样使用典型的 for 循环,我无法真正将头颅添加到 hashmap 中。例如,如果我有以下代码段:
(def empty-hashmap {})
(def big-hashmap (assoc empty-hashmap 1 2))
我将如何迭代并将 300 个单独的元素添加到大哈希图中?在这种情况下,我希望我的代码看起来像
(def empty-hashmap {})
(def big-hashmap (assoc empty-hashmap n (abundance n)))
其中 n 是数字 1 到 300,它将 300 个元素填充到大哈希图中。
【问题讨论】:
标签: clojure