On Nov 2, 9:01 pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Anh Hai Trinh <anh.hai.tr...@gmail.com> writes: > > > > Yes, just about any ‘map()’ operation has a corresponding list > > > comprehension. (Does anyone know of a counter-example, a ‘map()’ > > > operation that doesn't have a correspondingly simple list > > > comprehension?) > > > Try turning this into a list comprehension: > > > vectorsum = lambda *args: map(sum, zip(*args)) > > By “this” I take you to mean “the usage of ‘map’ in this code”, since > that's the limit of my question. > > >>> vectorsum = lambda *args: [sum(items) for items in zip(*args)] > >>> vectorsum([1,2], [3,4], [5,6]) > [9, 12] > >>> vectorsum([1,2], [3,4], [5,6], [7,8]) > [16, 20] > > -- > \ “The apparent lesson of the Inquisition is that insistence on | > `\ uniformity of belief is fatal to intellectual, moral, and | > _o__) spiritual health.” —_The Uses Of The Past_, Herbert J. Muller | > Ben Finney
prickly -- http://mail.python.org/mailman/listinfo/python-list