The function doesn't yield result

For the list [1,2,3,4,0],
the rule is:
1: +0.1
2 or 3: + 0.2
4: +0.4
other number: unchanged

so the result should be: [1.1, 2.2, 3.2, 4.4, 0]

But the funtion doesn’t yield result

def abc(Typ:var[])
{
return=[Imperative]
{
	L=[];
	for (i in 0..List.Count(Typ)-1)
	{
		if (Typ[i]==1)
		{
			t=Typ[i]+0.1;
		}
		elseif (Typ[i]==2 || Typ[i]==3)
		{
			t=Typ[i]+0.2;
		}
		elseif (Typ[i]==4)
		{
			t=Typ[i]+0.4;
		}
		else
		{
			t=Typ[i];
		}
	L=DSCore.List.AddItemToEnd(t,L);
	}
    return=DSCore.List.Flatten(L);
    }
};

Two things:

  1. you need to define t prior to assigning it in the loop
  2. I think that full name method lookups only work in Dynamo 2.7+, so you’ll need to remove the DSCore. part

2 Likes