I have a function scalar_func(*args)
that takes a variable number scalar numbers. It preforms some math with them and outputs a scalar. As a trivial example, we'll assume scalar_func
multiplies each number:
def scalar_func(*args):
out = 1
for arg in args:
out *= arg
return out
I would like to have scalar_func
work with lists. To do so, I made another function list_func(*args)
. It takes in a variable number of lists and makes a new one like so:
def list_func(*args):
out = []
for i in range(len(arg[0])):
out.append(scalar_func(arg[0][i], arg[1][i], arg[2][i]...)
return out
Obviously, this function is just pseudocode. How can I implement list_func
?