Shift List

поговоримо про більш складні маніпуляції зі списками. Наприклад нод Shift List Ось так виглядає результат його роботи і зараз трошки детальніше його розберемо.

Untitled

It is very important to consider the behavior of nodes with different lengths of lists. That is, in all previous examples with points and radii, the length of the lists was the same (the number of elements in the list).

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/d2fa1c8d-d321-4bfd-b936-4b57d3f3263f/Untitled.png

Now let's consider what will happen if we have one point and 3 radii. In this case, we still get 3 circles with different radii but with the same center.

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/47f3e346-310f-4782-ba1a-60204c0cf155/Untitled.png

Let's try the opposite - 3 points and one radius (we have already done this at the beginning of this section). And once again, we see that the result is 3 circles with different centers but the same radius.

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/6bdc7f12-f31f-4cc5-a00c-720324a808c2/Untitled.png

Now let's try 2 points and 4 radii. In this case, we get the following result: one circle on one point and three circles on the second point. This behavior may seem strange to you, but knowing its rule is enough to understand everything.

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/666d194c-82a8-4341-9755-3c66fb956733/Untitled.png

The first thing we always need to remember is that data lists have a clear sequence, so when we create any list, we must take this into account. After all, it is in that order that the main rule of working with lists in gh will be applied.

<aside> 📌 If we have several lists of different lengths, for example:

points - [ p1, p2 ] and radii - [ r1, r2, r3, r4 ]

then when we connect these lists to the Circle node, the following happens:

1/ The first point p1 is used to create a circle with a radius of r1.

2/ The second point p2 is used to create a circle with a radius of r2.

3/ We don't have a third point, but we have a radius, so we take the last point p2 from the list and apply the radius r3 to it.

4/ We do the same with the fourth radius r4 and use the last point from the list p2 as the position.

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/ad8b3cc4-7cf3-43cc-b91c-df54b59ec4c1/Untitled.png

</aside>

Remember the example with the balls at the beginning of the section on lists, it actually illustrates the basic principle of how gh works with data.

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/64e5a076-88db-4c60-8aaa-871b4e3c497d/Frame_16.png

https://prod-files-secure.s3.us-west-2.amazonaws.com/ee848b0b-0549-4363-9009-29b090347be4/e3cd2f2f-b97d-438f-b096-529fc6a4827e/Frame_17.png

Example with lines