Closed robhanlon22 closed 2 years ago
If all you care about is nodes at depth 1, then you can just use the path [:children ALL]
. For other depth values, you could dynamically construct a path targeting only that depth using comp-navs
to compose multiple (path :children ALL)
together. Otherwise, the generic technique for keeping track of your depth in a recursive path is to use value collection and then to check the number of collected values with collected?
.
Let's say I have a tree structure like this:
Now, let's say I want to do something only on nodes with a depth of 1, i.e. the nodes with values 2 and 3. Is this possible using
collect
, arecursive
, orwalker
? Or is there just something I'm not thinking of? Thanks in advance :)