Multiply numbers internally in a sublist

Hi,
Is it possible to multiply numbers of each sublist internally and get a result as shown below.

[[2,3,8,1,4],[5,8],[3,3,2]]
2*3*8*1*4 = 192
5*8 = 40
3*3*2 = 18

I can do this using Python or some package nodes but I’m looking for an OOTB solution.

If my ootb you mean an ootb node solution then you’re probably out of luck. You will likely need to create your own custom function, at which point Python would be much faster.

Example Code
def product(values : var[]..[])
{
	length = DSCore.List.Count(values);
	i = 0;
	current = 1;
	return = [Imperative]
	{
		while (i < length)
		{
			next = values[i];
			current = current * next;
			i = i+1;
		}
	return = current;
	}
};
3 Likes

Hi,

my first thought was also, this cant be done with OOTB nodes. but then I tried this just for kicks and it worked😅 who would have guessed that the math.evaulateformula would take numbers as a string type as parameters😂 multiplysublistOOTB.dyn (9.4 KB) .

5 Likes

I have never even seen that node. Thanks for the solution.

This node has some potential. Not sure what all it can be used for but…
image

2 Likes

@Nick_Boyts That worked like a charm! But I would definitely prefer Python over DS scripting like you suggested.

@terjefj That was amazing, I’ve never used or even knew about that node. Thanks for tinkering around and suggesting that!

Btw, I also came up with a solution but it involves making a custom node since I couldn’t apply List.Reduce on sublists.


1 Like