Any simpler way to combine lists?

1

List

t1 = [3, 4..6];
t2 = (7..9);
t3 = (1..2);
t4 = DSCore.List.Deconstruct(t1);
t5 = DesignScript.Dictionary.ValueAtKey(t4, "first");
t6 = DesignScript.Dictionary.ValueAtKey(t4, "rest");
t7 = DSCore.List.Flatten(t6, -1);
t8 = DSCore.List.Flatten(t5, -1);
t9 = [t3, t8, t7, t2];

Thanks for the solution.
I made my question more general:
1

so the List.Deconstruct(t1) may not work

I found a solution.

@Xiaofei_Ying See if this works …

a = List.Count(lst<1><2>);

b = [Imperative]
{
	c = 0;
	d = [];
	for (i in a)
	{
		b = List.UniqueItems(i);
		if (Math.Sum(b) == 1) {
			d[c] = Math.Sum(i);
			c = c + 1;
		}
		else {
			d[c] = i;
			c = c+ 1;
		}
	}
	return List.Flatten(d,-1);
};

List.Chop(List.Flatten(lst,-1),b);
2 Likes

Or you could use levels?

image

1 Like