specter

Latest version: 1.1.3
2018-02-06T16:12:39.000545Z

Hi, I have a nested data structure like in the snippet above. I can select all the nodes of a specified type, but I’m having trouble updating them. I want the index of the node I am updating within the transform function. Any pointers on how to do this? Thanks

nathanmarz 2018-02-06T16:33:53.000079Z

@jamescroft you can do that with subselect and a slightly modified NODES

nathanmarz 2018-02-06T16:33:55.000508Z

(def NODES (recursive-path [] p (stay-then-continue (must :nodes) ALL p)))
(transform [(subselect NODES #(= "a" (:type %)) :index) (view count)] range data)

2018-02-06T16:41:36.000553Z

@nathanmarz great thanks! I wouldn’t have got there on my own!

nathanmarz 2018-02-06T16:45:01.000119Z

sure thing

nathanmarz 2018-02-06T16:45:24.000027Z

I highly recommend skimming through https://github.com/nathanmarz/specter/wiki/List-of-Navigators to learn what's available