On Mar 18, 2:23 am, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > > max(i for i,t in enumerate(x) if t <= y) > > > Those are actually pretty direct. > > > How about a solution (like the bisect one suggested almost as soon as > > this thread started) that doesn't iterate over the whole list. > > Here's a Haskell-inspired one: > > len(list(itertools.takewhile(lambda t: y > t, x))) >
Can you explain how list() works in that statement. I looked up takewhile() and it returns an iterator that will automatically stop at the insertion point? So does list() do an internal comprehension with the iterator? -- http://mail.python.org/mailman/listinfo/python-list