Strange LoopWhile

Again, the strange and mysterious loopwhile is unclear how it works or even where the code flows.??? And I don’t understand what is missing it to work ???

LoopWhile.dyn (17.2 KB)

HI
i think you just need to disconnect the wire between the “0 in code block” and " < smaller than node"

2 Likes

Done that and it gives me just one iteration .

What results are you expecting?
Can you show all of the inputs nodes with their preview expanded?

1 Like

I am expecting a list containing integers from 1 to 17

Then you don’t want a while loop. You want to build a range. Dynamo Dictionary

3 Likes

I am using List.item.addtoend to accomplish that purpose

@jacob.small

Thanks Jacob for that recommendation ! It fulfilled the purpose but I still don’t know how a LoopWhile operates ?? It’s a very weird node and counter intuitive.

1 Like

Loop while will take an object, and perform a function on that object until a condition has been met.

Because your object is a single object (an number), the result will always be a single object (a number). If you wanted to take the last value from a list, add one to it, and append the new value to a list until the value was greater than another number this would also work, but the function would be significantly more complex, the actions orders of magnitude slower, and the results the same as what was posted above. Such an effort in Dynamo is quite advanced - in fact loopwhile is best left for users with a few months of experience.

2 Likes

I am a bit confused by the difficulty of implementing it in a visual scripting tool.

Out of interest could you post something showing us an example or two of it in use?

I’ve always been confused by it too, despite using loops on a regular basis in Python for the last couple of years now.

1 Like