Match Multi-level Lists

  1. How to get result 1 and 2 using number lists A and B?
    I tried list@level with different @L combination, but can’t get target results.

  2. How to get result 3 and 4 using string lists A and B?
    Match Multi-level Lists.dyn (23.5 KB)

Hi @Xiaofei_Ying
Number 1:
image

Number 2:
image

Is this what you were looking for? :slight_smile:

@ CVestesen

I should have made my thread more clear.

  1. As for the number lists, I want to do multiplication between A and B: [1,2] * [1,2,3]=[1,2,3],[2,4,6], [3,4] * [4,5,6]=[12,15,18],[16,20,24], and keep structure like result 1 and 2, respectively.

  2. As for the string lists, I want to do some kind of combination between A and B: [1,2] and [a,b,c] = [1a,1b,1c],[2a,2b,2c], [3,4] and [d,e,f]=[3d,3e,3f],[4d,4e,4f], and keep structure like result 3 and 4, respectively.

1 Like

Is there a reason they have to be nested list of lists? You have the entire thing encased in a list as the only element in the list. You can make a python script that would work only for the exact structure you showed pretty easily but if the structure changes, it won’t work anymore. Like below:


xiaofei_matchmultilevellists.dyn (10.0 KB)

2 Likes

If you need the match string lists as separate lists (result 4 I think):

alist = IN[0][0]
blist = IN[1][0]
clist = []

# Place your code below this line
for a, b in zip(alist, blist):
	c = []
	for _a in a:
		_c = []
		for _b in b:
			_c.append(str(_a) + _b)
		c.append(_c)
	clist.append(c)

OUT = clist
1 Like

@ kennyb6
Thanks. Look like there is no way to use built-in nodes to achieve the targets.

Doesn’t seem like it. Not without using an imperative function in a code block, which will be no different than a python node.