# How the effective use index shift list?

I’m a beginner to use a dynamo. I happened to come across an example of “Generate points across all the circles using point parameter. Using shift index, you shifted each of the points grouped along the circle by one point at each step. This makes the points rotate around the circle by 1 index at each ring. Using list transpose, I am able to generate nurb curve across all points to create the helix above” Problem here is just the application list on the education index dynamoprimer.com shift on how the shift index used list.
How to shift the index list as above using the example that I see?

Hi,

Thank kulkul. Seems I was rushed in to post. :thư giãn:

ShiftIndex basically ‘rotates’ the objects in a list. If you imagine a list has slots (the indexes) and in each slot is an object - in your case, its points. The slots are then on a continuous conveyor belt, and as you increase the amount of the shift each slot steps forward (i.e. rotates) by that amount but the indexes of the list are going to remain the same. Since its a continuous conveyor belt, the object at the end of the list doesn’t fall off (i.e. get deleted), it simply rejoins the front of the queue so you end up with a continuous cycle (hence why describing the behaviour as a rotation is accurate).

If we now apply this concept to your model, each circle has a corresponding shift, so circle1 has a shift amount of 0, circle 2 has a shift amount of 1, etc, etc. This shift is then applied to the list of points on each circle, and when joined by lines, it results in a twisting effect of the members.

Hope that makes sense.

1 Like

I tried to understand it by doing the steps manually. But it really does not work. There’s something inside it is not right. File dynamo: Tao ra vong xoay parameter.dyn (35.6 KB)

Your error is caused by overlapping points as you are creating them on closed curves (i.e. circles).

The shift list is working correctly, but where the start point coincides with the endpoint it gives the impression that the list is not being shifted. Just add a drop item here:

Correct result:

Also, you wired up the wrong list here, so you’ll need to correct this too:

And you should learn some coding too, it would prevent the need to duplicate nodes exhaustively. This code does your shifts in a single node and can handle as many lists of points you can throw at it: ``````pt:Point[][];

ptRotate = [Imperative]
{
ptOUT = {};
for (i in GetKeys(pt) )
{
ptOUT[i] = List.ShiftIndices(pt[i], i);
}
return = ptOUT;
};``````
1 Like

Thank you very much.:cười toe toét: This code table really effective. It is what I was looking for so long and I can learn how to write this code from?

You can get the job done by replacing that group of nodes in your definition by just two nodes a indicated below…
By doing so you also ensure that your definition works even when the input list length changes.