Loop if logic help

Hi guys, I have been working with some code blocks in dynamo and trying to learn its syntax and logic, however I cannot figure out where I am getting this one wrong.

Apparently, I should be getting some true values as my code block result but it is not working :confused: I have tried switching up some values // variables and orders but I canĀ“t seem to get it to work :confused:

Here is my code block :slight_smile: It should be a simple task but I canĀ“t sort this one out.

Tks!

Hi @camirozario

The problem is the level of the inputs:

Without level:

With level:

In this case you need to use the [i] action for the y list too.

z;
x;
y;

loop = [Imperative]
{
	result = [];
	for (i in 0..z-1)
	{
		if (x[i] <y[i]) {
		result [i] = true;
		}
		else{
			result[i] = false;
		}
			}
			return result;
};
2 Likes

Oh, that makes sense! Thanks so much. I am still getting how the level and list structure works so I didnĀ“t think this could be the issue. But that was exactly it! Thank you so much for the help

1 Like

@camirozario Youā€™re welcome! :slight_smile:

Maybe this article will help you understand the levels:

2 Likes

Super cool stuff! Will definitely read it!

Thanks again @jw.vanasselt

2 Likes

hello
An excellent, clear and precise presentation by Mr. Sol Amour on the designscript (pdf file)

Answer without imperative block

code block:

x;
y;
z=DSCore.List.Count(x);
//Your filter
filter=x[0..(z-1)]<y[0]?true:false;
//Your result
R=DSCore.List.FilterByBoolMask(x,filter);
Result=Dictionary.ValueAtKey(R,"in");

cordially
christian.stan

1 Like