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
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
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
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
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