Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30462

Re: creating an artificial "last element" in sort list

References <7cd170ac-bb14-4baa-93ea-530c569d3985@googlegroups.com> <mailman.1587.1348875975.27098.python-list@python.org> <b3564f31-f54c-4c00-a6e7-f497911c054a@googlegroups.com> <mailman.1591.1348878745.27098.python-list@python.org> <16506499-9803-4f68-8269-f201863574c9@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-09-28 21:29 -0600
Subject Re: creating an artificial "last element" in sort list
Newsgroups comp.lang.python
Message-ID <mailman.1601.1348889426.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Sep 28, 2012 at 6:59 PM, Demian Brecht <demianbrecht@gmail.com> wrote:
>> f = filter(lambda s: s == a[-1], a)
>
> That line's assuming that the last element may also be found in arbitrary locations in the list. If it's guaranteed that they're all contiguous at the upper bounds, I'd just walk the list backwards until I found one that wasn't matching rather than filtering.

The slicing operation in the second line assumes that they're all
collected at the end of the list anyway.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:39 -0700
  Re: creating an artificial "last element" in sort list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 17:45 -0600
    Re: creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:51 -0700
      Re: creating an artificial "last element" in sort list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-28 17:24 -0700
      Re: creating an artificial "last element" in sort list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-28 17:24 -0700
      Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:32 -0700
        Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:59 -0700
          Re: creating an artificial "last element" in sort list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 21:29 -0600
        Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:59 -0700
      Re: creating an artificial "last element" in sort list duncan smith <buzzard@invalid.invalid> - 2012-09-29 02:19 +0100
    Re: creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:51 -0700
  Re: creating an artificial "last element" in sort list Paul Rubin <no.email@nospam.invalid> - 2012-09-28 18:42 -0700
  Re: creating an artificial "last element" in sort list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-29 02:05 +0000

csiph-web