Using Loops to get item at index

So i have three lists
L1 is the value in wich i’ll look into L2
i want to get the index of the number wich is the first one bigger than L1 in L2
then, with this index i’ll get the value in L3
I’ll attach a picture to better describe it
together with the Dyn file

PS: i already managed to find a solution for it using a workaround, but i really would like to use loop structures to solve it.image
Thanks everybody for your help

what is >> ?
I don’t think DS has right shift :wink:


Is this it?


value_found = [Imperative]
	i = 0;
	looking_for_value = true;

	while (looking_for_value)

		if	(list_to_compare[i] > value_to_find)
		looking_for_value = false;
		return = i;

	i = i + 1;

Home.dyn (3.4 KB)

1 Like

I don’t know what is happening, but everytime i try to do this code, Dynamo crashes…

Edit: I just had to turn the execution mode to manual and link the lists…

By the way, is there a guide for understanding the imperative coding style?
i have to addimit i know nothing about it

A good resource for me for understanding DesignScript would be this Design Script Manual as well as the Dynamo Primer.

I believe Imperative starts around page 6 in the manual and maybe more, you can CTRL+F to find where it describes more imperative coding.

1 Like