Clojure中的线程注释
我希望能够在树数据结构中插入内容(比如对discus、Hacker News等做评论的内容)。如果能以一种巧妙的功能性方式来实现,那将是一件好事 范例Clojure中的线程注释,clojure,functional-programming,tree,Clojure,Functional Programming,Tree,我希望能够在树数据结构中插入内容(比如对discus、Hacker News等做评论的内容)。如果能以一种巧妙的功能性方式来实现,那将是一件好事 范例 (def cmts [{:name "Abi" :id 1 :text "Great question" :children nil} {:name "Bib" :id 2 :text "What about zippers?" :children [{:name "Linus" :id 3
(def cmts [{:name "Abi" :id 1 :text "Great question" :children nil}
{:name "Bib" :id 2 :text "What about zippers?" :children
[{:name "Linus" :id 3
:text "I don't understand how to and insert
children at a certain id with them"
:children nil}]}])
问题是如何插入这样的注释
(add-comment cmts :name "Iba" :text "I think so too!" :in-reply-to 1)
以某种简洁/优雅的方式
或者:解决问题的更简单方法是什么?如果您希望进行功能树编辑(编辑嵌套数据结构),那么可能
是正确的工具。我意识到clojure.walk库中有非常好的功能可以实现这一点