MCPcopy Create free account
hub / github.com/ActiveState/code / sumInList

Function sumInList

recipes/Python/278257_List_Tools/recipe-278257.py:151–155  ·  view source on GitHub ↗

Given a complexList [ [a1,b1,c1], [a2,b2,c2], [a3,b3,c3] ], return a list [ a, b, c] where a = a1+a2+a3, etc.

(complexList)

Source from the content-addressed store, hash-verified

149
150#========================================================================
151def sumInList(complexList):
152 ''' Given a complexList [ [a1,b1,c1], [a2,b2,c2], [a3,b3,c3] ],
153 return a list [ a, b, c] where a = a1+a2+a3, etc.'''
154 d = rezip(complexList)
155 return [ reduce(lambda x,y:x+y, z) for z in d ]
156
157#========================================================================
158def avgInList(complexList):

Callers 1

sumInDictFunction · 0.50

Calls 1

rezipFunction · 0.70

Tested by

no test coverage detected