specter

Latest version: 1.1.3
idiomancy 2019-03-15T20:29:53.024700Z

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:

idiomancy 2019-03-15T20:47:50.025500Z

oh damn, yeah, recursive-path just throws the params out after the first macro call

idiomancy 2019-03-15T21:12:38.025900Z

anyone here know how to use collected vals mid navigation?

idiomancy 2019-03-15T21:29:49.026300Z

lol. here's my shitty implementation:

idiomancy 2019-03-15T21:29:58.026500Z

idiomancy 2019-03-15T21:31:01.027200Z

(spr/select TREE-VALUES-AND-LEVELS [1 [2 [3 4] 5] [[6]]])
=> [[0 1] [1 2] [2 3] [2 4] [1 5] [2 6]]

nathanmarz 2019-03-15T22:51:55.027600Z

@idiomancy you would need more control over collected vals to do that elegantly

nathanmarz 2019-03-15T22:52:01.027800Z

(transform ALL
  (fn [v]
    [(-> v count dec) (last v)]
    )
  (select TREE-VALUES-AND-LEVEL [1 [2] [[3] 4 [5 6]]]))

idiomancy 2019-03-15T22:54:44.029200Z

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

idiomancy 2019-03-15T22:55:27.030100Z

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

idiomancy 2019-03-15T22:56:03.030600Z

I'd like to chain this into a longer path, so doing it without the transform macro would be nice