I want to calculate the center-of-mass using the map function. I don't want to use for loops. Help with bottom two lines?
class Obj():
def __init__(self, mass = 0., x = 0., y = 0.):
self.mass = mass
self.x = x
self.y = y
# Create List of Objects
objList = []
n = 0
for i in range(0,10):
for j in range(0,10):
objList.append(Obj(i*j,i,j))
# Calculate Center of Mass of List
# The following is pseudocode, does not actually work
SumOfMass = sum(objList[:].mass)
CenterOfMassX = sum(objList[:].x.*objList[:].mass)/SumOfMass