def interleave(inter, f, seq):
 seq = iter(seq)
 try:
  f(seq.next())
 except StopIteration:
  pass
 else:
  for x in seq:
   inter()
   f(x)

def interleave ( inter , f , seq ) : seq = iter ( seq ) try : f ( seq . next ( ) ) except StopIteration : pass else : for x in seq : inter ( ) f ( x )
call f on each item in seq .