Get specific sublist items (w/o replication)

I haven’t found a specific answer to this topic in the forums (though several came close)

I have a 2D list (call it master list), think of it as a grid (list of rows, each row with individual items).

I have a second list (call it locator list). it has a bunch of sublists with 2 individual items in each sublist. (think of it as x/y coords. So it is a list made up of sublists, each with an X and a Y value).

My goal is to use use the values in the ‘locator list’ to grab the corresponding values in the ‘master list’. So if the first sublist in the ‘locator list’ has values 20 & 40, use that to grab the 40th item in the 20th sublist from the ‘master list’.

Thoughts?

Hard to say without seeing how the lists are made up. Can you show some of the work you’ve done up till now?

1 Like

Thank you Vikram
Well, now I feel dumb…

Perhaps I was trying to be too clever with my solution choice

1 Like

One more follow-up.
Tomasz… the python script did not like the fact that I was using lists as inputs. (so, master list index would be a list. and sublist index would also be a list)

Vikram… Is there a way to do this without creating an intermediate list? The dataset I am working is pretty big. So, the first list (from List.GetItemAtIndex) has over a million items and it is overloading my system.

Update…
got it to work with a for loop

def colorFinder(mList:var[][],indX:var[],indY:var[],len:var[])
{
	return=[Imperative]
	{
		lst={};
		i=0;

		for (i in len)
		{

			xVal=indX[i];
			yVal=indY[i];
		
			lst[i]=mList[yVal][xVal];
			i=i+1;

		}


		return=lst;
	}

};
1 Like