2012-03-12 3 views
4

나는 Disqus, Hacker News 등에 대한 코멘트를하는 것처럼 트리 데이터 구조에 삽입을하고 싶습니다. 그리고 영리한 기능적 방식으로 그것을하는 것이 좋을 것입니다.Clojure의 쓰레드 된 코멘트

(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) 

같은 메모를 삽입하는 방법입니다.

또는 문제를 해결하는 간단한 방법은 무엇입니까?

답변

3

기능적 트리 편집 (네스트 데이터 구조 편집)을 수행하려는 경우
zipper library이 적합한 도구입니다.