Find first in sequence (simple question)  Neal D. Becker
ndbecker2 at Mon Sep 13 22:03:36 CEST 2004  Neal D. Becker
wrote:  > What is an efficient way to find the first element in
a sequence meeting > some condition? > For example, the first
number > x in a list of numbers.  I guess if the sequence is
sorted, you could use bisect, but only for the specific case of
comparing the values.  I really was looking for a more general
"find_first" function, that would find the first occurance in a
sequence meeting some predicate, with short-circuit evaluation
(not evaluating the function for every element  More information
about the Python-list mailing list