Cross product on a List and sublist

Hello guys,

I think it’s a school case but I loose my mind on this tiny code.

These two lists below have the same length.

Here what I Intend to do :

Can you help me please ?

Thanks for your answers.

When getting into this sort of weird list manipulation exercise I find it much easier to go down the Python route (see below).

Murs_walls = IN[0]
Murs_joint_walls = IN[1]

#zip the lists to create the groups
combined = zip(Murs_walls, Murs_joint_walls)

new_lists = []
# for each zipped list
for zipped_list in combined:
	# Get the top wall
	Murs = zipped_list[0][0]
	# For each sub wall under the top wall
	for Murs_joint in zipped_list[1]:
		# Append a list containing the top wall with the sub wall

OUT = combined, new_lists

Just plug your wall lists in instead of my list of integers.

I’m sure @Dimitar_Venkov would be able to do this in 1 block of design script but I’m working with the tools I’ve got :laughing:

1 Like

@haganjake2 is right, you have way more control in python.

When working in DesignScript/nodes, however, the best thing you can do is keep equal list structures to make everything a one-to-one input in your function.


Thanks a lot @haganjake2 , it works perfectly. I must definitely learn Python language !

Thanks too @Nick_Boyts !!

High speed solution !! :smiley:

1 Like

Ahhh yes, of course, that’s a much smarter way to go about it.

Was being narrow-minded with my choice of nodes for creating new lists.

Can’t say I’ve used add item to front much before! Another useful one to be aware of.

1 Like

If I understood correctly, another alternative:

lst = DSCore.List.SetUnion(x<1>,y<1><1>);
out = DSCore.List.Flatten(lst@L2<1>,-1);
1 Like