Luis Quesada
3/28/2010 10:15:00 PM
Paul Rubin wrote:
> Luis Quesada <l.quesada@4c.ucc.ie> 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 ifilter, but it's not worth it.
>
> For the style of programming you're interested in, you should read the
> docs for the itertools module. Python culture in general tends to
> not be that fond of heavy use of HOF's, since it's very easy to make
> mistakes with its iterator protocol and with its dynamic type system.
Thanks a lot for the pointer.
Python is rather cool indeed.
Cheers,
Luis