Loop in a List

Hello All,

Looking for a simple recursive loop code example using Design Script code block that i can send a list of objects though rotating some of them with each loop.
I looked for several examples here on the forum, but I was unable to develop the reasoning, which would be like the image below.

As I noticed several users with great knowledge, maybe someone can help me how can I solve it?

Hi @renanemeyer,
Welcome to the Dynamo community.
I don’t think you will need a loop or recursion of any sort if you just want to get an output as shown in ReturnList.
See if this works for you:

cnt = List.Count(myList);
dropList = -cnt+1..0;
massAddList = List.DropItems(myList-1,dropList);
massAdd = Math.Ceiling(Math.Sum(massAddList));
output = "line"+(massAdd+(1..cnt));
1 Like

Very well!

both worked, I’ll be able to continue with the code :clap:

Thank you so much for your feedback and solution, it helped me a lot

1 Like