thanks @nathanmarz! got another one for you... how does one use recursive navigators that have arguments?
(def TREE-VALUES-AND-LEVELS
(spr/recursive-path
[nesting] p
(spr/if-path vector?
[spr/ALL (p (inc nesting))]
[(spr/putval nesting) spr/STAY])))
=> p.call is not a function
:white_frowning_face:oh damn, yeah, recursive-path just throws the params out after the first macro call
anyone here know how to use collected vals mid navigation?
lol. here's my shitty implementation:
(spr/select TREE-VALUES-AND-LEVELS [1 [2 [3 4] 5] [[6]]])
=> [[0 1] [1 2] [2 3] [2 4] [1 5] [2 6]]
@idiomancy you would need more control over collected vals to do that elegantly
(transform ALL
(fn [v]
[(-> v count dec) (last v)]
)
(select TREE-VALUES-AND-LEVEL [1 [2] [[3] 4 [5 6]]]))
> you would need more control over collected vals to do that elegantly so wait, did you see my first implementation? Is there some way to make that work?
(def TREE-VALUES-AND-LEVELS
(spr/recursive-path
[nesting] p
(spr/if-path vector?
[spr/ALL (p (inc nesting))]
[(spr/putval nesting) spr/STAY])))
because that would let me do it without re-transforming the output of the recursive nav. I mean this is definitely a conceptually recursive operation
I'd like to chain this into a longer path, so doing it without the transform
macro would be nice