Find first in sequence (simple question)
Neal D. Becker
ndbecker2 at verizon.net
Mon Sep 13 16:03:36 EDT 2004
More information about the Python-list mailing list
Mon Sep 13 16:03:36 EDT 2004
- Previous message (by thread): Find first in sequence (simple question)
- Next message (by thread): Find first in sequence (simple question)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 first).
- Previous message (by thread): Find first in sequence (simple question)
- Next message (by thread): Find first in sequence (simple question)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list