Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure中的线程注释_Clojure_Functional Programming_Tree - Fatal编程技术网

Clojure中的线程注释

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

我希望能够在树数据结构中插入内容(比如对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 
              :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库中有非常好的功能可以实现这一点