Hi,
I need to update a tree of unknow breadth and depth.
As I learn best through examples, do you have examples, links, docs, … on how to ‘update’ complex data structures in clojure? Is Specter the way to go?
Say we have the following nested structure (breadth and depth not known in advance), containing a relative file path (:path , in this example) in respect with the parent. If that relative path is empty or missing, then the full path is the same as the parent’s full path
[{:level 0, :properties {:path "~/"}}
[{:level 1, :properties {}}
[{:level 2, :properties {:path "1100"}}]
[{:level 2, :properties {:path "1200"}}
[{:level 3}
[{:level 4, :properties {}}]
[{:level 4, :properties {:path "1201"}}]]]
[{:level 2, :properties {:path "1300"}}
[{:level 3, :properties {:path "1310"}}]
[{:level 3, :properties {:path "1320"}}]]]
[{:level 1, :properties {:path "999"}}]]
I’d like to return the same data, but with a new property :full that is a concatenation of the relative path with all the paths of all the parents up to the root. (And if the relative path of the parent is empty, then use the full path of the parent’s parent)
[{:level 0, :properties {:path "~/" :full "~/"}}
[{:level 1, :properties {:full "~/"}}
[{:level 2, :properties {:path "1100" :full "~/1100/"}}]
[{:level 2, :properties {:path "1200" :full "~/1200/"}}
[{:level 3, :properties {:full "~/1200/"}}
[{:level 4, :properties {:full "~/1200/"}}]
[{:level 4, :properties {:path "1201" :full "~/1200/1201/"}}]]]
[{:level 2, :properties {:path "1300" :full "~/1300/"}}
[{:level 3, :properties {:path "1310" :full "~/1300/1310/"}}]
[{:level 3, :properties {:path "1320" :full "~/1300/1320/"}}]]]
[{:level 1, :properties {:path "999" :full "~/999/"}}]]
Thanks in advance for any response that could help me!