Anemone to iterate through list?

Hi, I am trying to use anemone loops to iterate through a list and execute a function for each index.

This is a university coursework that tries to analize and recreate the stalled World Islands in Dubai. I need each point in the island cluster to find its closest “port” and output all those lines at once. The function inside the loop is what does that, and I wanted to repeat that as many times as there are points, but there seems to be something missing as it only runs once. The data outputted is correct in the sense that the number is always increasing by 1 up to 155, but that “new” number is not being passed on as a list index, which always stays as 0. Am I screwing up the connections? does the solution look totally different?

Dear Franeb,
You dont need loops here. Just use closet point component. In the “P” insert the island point(graft the input) and in “C” insert the port points( flatten list). The just make a line between the island point and the new found closest point. Hope this helps!
Mr A.

1 Like

Thanks! I didn’t realize, I guess I inmediately thought of ways to solve it with recursion. Is it possible to know if there is an actually workable solution to iterate through list indexes, for other challenges that might arise in the future?

Instead of using data(I/O) for index number use counter- now the data(I/O) is free . Add merge component on canvas Connect “D1” input of merge to final curve container. And"D2" to data output from (loop start) component And output of the curve to the "data " input on loop end component.
You will get all the desired curves on the data output on loop end component. Lmao too lazy to fire up rhino.
Mr A.

Wow thanks man, I used it for something else and it worked. I feel like I’ve just unlocked a whole new level of Grasshopper power. I have been very excited about loops since taking some written python courses and it was the one thing I thought GH was missing.