reduce()--what is it good for? (was: Re: reduce() anomaly?)

Georgy Pruss SEE_AT_THE_END at hotmail.com
Fri Nov 7 10:34:21 CET 2003


seq=[1,3,4,7]
map( int.__sub__, seq[1:], seq[:-1] ) # nearly twice faster than ....zip.... for long arrays

G-:

"David Eppstein" <eppstein at ics.uci.edu> wrote in message news:eppstein-D499AF.21573206112003 at news.service.uci.edu...
> In article <mailman.507.1068171071.702.python-list at python.org>,
>  Bob Gailer <bgailer at alum.rpi.edu> wrote:
>
> <...>
> > seq = [1,3,4,7] we'd like a differences == [2,1,3].
> >
> <...>
>
> seq=[1,3,4,7]
> [y-x for x,y in zip(seq,seq[1:])]
>
> -- 
> David Eppstein                      http://www.ics.uci.edu/~eppstein/
> Univ. of California, Irvine, School of Information & Computer Science







More information about the Python-list mailing list