Manipulating Sublists


#1

I’m trying to figure out a recursive node that will let me take a nested list, apply a parameter to each sublist, and reconstruct the list with the changes. I feel like this should be a pretty simple exercise, but I’m definitely missing something.

 

This is massively simplified, but how would I go about using the Shift List Indices node to turn this:

 

[0]

 

[0] 0

 

[1] 1

 

[2] 2

 

[3] 3

 

[1]

 

[0] 0

 

[1] 1

 

[2] 2

 

[3] 3

 

[2]

 

[0] 0

 

[1] 1

 

[2] 2

 

[3] 3

 

 

 

and turn it into this:

 

 

[0]

 

[0] 2

 

[1] 3

 

[2] 0

 

[3] 1

 

[1]

 

[0] 2

 

[1] 3

 

[2] 0

 

[3] 1

 

[2]

 

[0] 2

 

[1] 3

 

[2] 0

 

[3] 1

 

 

I understand getting the first index, applying the shift, and partitioning the list back to being nested, and I’m pretty sure I understand the iterative nature of the If node. What I don’t understand is how (or when in the chain of actions) to reconstruct the one-deep nested list.

 

Does that make sense? Any thoughts?


#2

Thank you, Andreas!


I knew there had to be a simpler way to do it, but every search I did led me back to recursion as the unexpected answer. I'm obviously very new to this, so I really appreciate your help.




#3

Why would you want to make a recursive node for this?


The Map node is your friend. ;-)