Help with using Replace Path instead of Path Mapper

I’ve been using Path Mapper for a while now but as my definitions get more complex I’m starting to run into the common problem of it failing for dynamic inputs. I have thus started to learn how to use Replace Path but am struggling to implement a few tree manipulations. For example,

Here I have four groups of manipulations for achieving the same output tree structure. The first group is just the default Path Mapper usage.

The second group is my attempt at making Path Mapper more robust by using wildcards, since I’m only interested in the last branch indices; I’ve had to include the “A” qualifier before the wildcard since it doesn’t allow me to start with the wildcard. After some light testing it seems to hold for dynamic inputs.

In the third group, I use Replace Path but with explicitly written masks, which will not hold if the number of branches at the top most level changes.

The fourth group is my attempt at dynamically generating the required paths. I think some combination of Tree Statistics and Deconstruct Path is needed, but it still looks like I need to manually flip the indices?

I’d appreciate some general tips or best practices on using Replace Path in this manner, since I do want to extend this to more complicated manipulations, for example how would I use it to implement mappings like {A;B;C}(i) → {C;i}? I know there is a 3-line dynamic path mapper script floating around which will probably serve me well, but I’m curious what the “Grasshoppery” way is to avoid the Path Mapper component as a whole.

replace_path_question.gh (14.7 KB)

Does this work for you?

replace_path_question.gh (24.7 KB)

Yes your solution works well, thank you! I hadn’t thought of using List Item. I’ve tried extending this method to my more complicated example of the mapping (A;B;C}(i) → (C;i), and have come up with the following:

Is this the best/most compact approach? I don’t think this will hold for manipulations involving three qualifiers or more, like {A;B;C}(i) → {C;A;i}, since Flip Matrix wouldn’t work. Is there no generally robust approach using Replace Path that is as compact as Path Mapper? It does seem like a lot of boilerplate that I wouldn’t want mixed in with the business logic, compared to using a single Path Mapper component.

replace_path_question.gh (14.0 KB)