Re: map, index

2010-03-28 Thread Luis Quesada
Paul Rubin wrote: Luis Quesada writes: [ id*v for id,v in enumerate(L) ] Cool! Thanks! If you really want to write that in pointfree style (untested): import itertools, operator ... itertools.starmap(operator.mul, enumerate(L)) For your other question, you could probably do someth

Re: map, index

2010-03-28 Thread Paul Rubin
Luis Quesada writes: >> [ id*v for id,v in enumerate(L) ] > Cool! Thanks! If you really want to write that in pointfree style (untested): import itertools, operator ... itertools.starmap(operator.mul, enumerate(L)) For your other question, you could probably do something ugly with ifil

Re: map, index

2010-03-28 Thread Luis Quesada
Duncan Booth wrote: Luis Quesada wrote: Is there a way of writing the following without using zip: map(lambda (id,v):id*v,zip(range(len(L)),L)) [ id*v for id,v in enumerate(L) ] Cool! Thanks! Cheers, Luis -- http://mail.python.org/mailman/listinfo/python-list

Re: map, index

2010-03-28 Thread Duncan Booth
Luis Quesada wrote: > Is there a way > of writing the following without using zip: > map(lambda (id,v):id*v,zip(range(len(L)),L)) [ id*v for id,v in enumerate(L) ] -- http://mail.python.org/mailman/listinfo/python-list

map, index

2010-03-28 Thread Luis Quesada
Dear all, I am new to Python, so I apologize in advance if you find my questions naive (or if they have been already answered in this forum). 1. What is the most pythonic way of mapping a list where the value each element is mapped to depends on the index of the element. Is there a way of wr