我是Clojure的新人.我在Clojure Koans的帮助下学习.我找到了以下代码的答案:
(= ["Real Jerry" "Bizarro Jerry"]
(do
(dosync
(ref-set the-world {})
(alter the-world assoc :jerry "Real Jerry")
(alter bizarro-world assoc :jerry "Bizarro Jerry")
(vec (map #(:jerry @%) [the-world bizarro-world]))))))
Run Code Online (Sandbox Code Playgroud)
来自:https://github.com/viebel/clojure-koans/blob/master/src/koans/16_refs.clj#L42
谷歌搜索"Clojure @%"是非常不友好的.所以我从互联网上得不到什么.
它如何用于"#(:jerry @%)"功能?
以下代码是我的答案,但它不起作用.
(= ["Real Jerry" "Bizarro Jerry"]
(do
(dosync
(ref-set the-world {})
(alter the-world assoc :jerry "Real Jerry")
(alter bizarro-world assoc :jerry "Bizarro Jerry")
(vec (map (fn [x] (:jerry x)) [the-world bizarro-world]))
)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
325 次 |
| 最近记录: |