Algorithm help per favore
jeremy at zope.com
Wed Jun 18 21:17:24 CEST 2003
On Wed, 2003-06-18 at 14:56, David Eppstein wrote:
> In article <3EF0AAFB.DDA5F555 at engcorp.com>,
> Peter Hansen <peter at engcorp.com> wrote:
> > > >>> L = [6,3,3,3,5,7,6,3,4,4,3]
> > > >>> [x for x, y in zip(L, [L]+L) if x != y]
> > > [6, 3, 5, 7, 6, 3, 4, 3]
> > But this won't work if L contains a reference to L! :-) :-)
> Ok, what's the quickest way to build a new object that's guaranteed
> unequal to any previous object? E.g.
> [x for x, y in zip(L, [lambda x:x]+L) if x != y]
> There must be a better way to do this than with a lambda.
How about "object()"?
More information about the Python-list