Last iteration?
Paul Hankin
paul.hankin at gmail.com
Thu Oct 18 03:52:57 EDT 2007
On Oct 17, 11:45 pm, Raymond Hettinger <pyt... at rcn.com> wrote:
> [Paul Hankin]
>
> > def lastdetector(iterable):
> > t, u = tee(iterable)
> > return izip(chain(imap(lambda x: False, islice(u, 1, None)),
> > [True]), t)
>
> Sweet! Nice, clean piece of iterator algebra.
>
> We need a C-speed verion of the lambda function, something like a K
> combinator that consumes arguments and emits constants.
Perhaps, but I think you'll need a better use-case than this :)
Actually, would a c-version be much faster?
--
Paul Hankin
More information about the Python-list
mailing list