Very dumb question — what would be the easiest way to track the depth of working through a tree? Trying to parse a nested map of data into an asciidoc — top level items are, say, titles of chapters, children from there are titles of sub chapters, children from there are paragraphs of text, or something like that. I want to concatenate all of that into a big string, but the formatting varies depending on position of depth. Is incrementing or decrementing an atom the most straightforward approach? Currently indifferent to building something like recursive-path vs zippers, but not sure if either is an intuitively more obvious choice
you can do something like this:
(def TREE-NODES
(recursive-path [] p
(if-path vector?
[(collect-one (view (constantly 1))) ALL p] STAY)))it collects a new value for every level of the tree it traverses
just the value 1
the last element in the transform fn or selected element will be the navigated value, and the rest of the values will be 1
so you can tell the depth by just taking the size of the vector