Change list indices

Hi people,

I have a list with items representing the original index from a previous list that i need to match in order for the script to work. Is it possible to use this list to substitute the original indexes into the new list ?

Thank you in advance!

Welcome @Federiches,

I’m not exactly sure about what you want to do?

On the left, you have an indexed list and on the right a tree with matched branches, it seems. You can think of a tree as a nested list (or list of lists). Technically what you’re pointing at is not an index but the path of the branch at {0;912} that has two items at indices 0 and 1.

Example 1

If you for instance want to apply each number of the list on the right to the corresponding branch of the data tree on the left, you can simply graft your list and you should end up with matching tree branches. What ever operation you do next that you use both trees for, the single item of your grafted list will be applied to all surfaces in the corresponding branch.

Example 2

There might be some cases where you want to match item per item exactly. Now, when you don’t have two trees with matching items in each branch - like you do after grafting -, but an equal number of branches, you can also duplicate the data of the short tree to bring it up to size.

Also, it would have been nice to have a file to work with!

Thank you for your response,

I understand tree structure but what I wanted to do is simply to change the branch index and replace the 0 to 912 with the corresponding items in th list on the left. So for example the beach index 911 becomes 877 and 912 becomes 1275.


1 Like