def index_if(predicate, seq):
 idx = 0
 for x in seq:
  if predicate(x):
   return idx
  idx += 1
 return idx

def index_if ( predicate , seq ) : idx = 0 for x in seq : if predicate ( x ) : return idx idx += 1 return idx
returns the index of the first element in sequence seq satisfying predicate .