def dmp_apply_pairs(f, g, h, args, u, K):
 if (not u):
  return dup_apply_pairs(f, g, h, args, K)
 (n, m, v) = (len(f), len(g), (u - 1))
 if (n != m):
  if (n > m):
   g = (dmp_zeros((n - m), v, K) + g)
  else:
   f = (dmp_zeros((m - n), v, K) + f)
 result = []
 for (a, b) in zip(f, g):
  result.append(dmp_apply_pairs(a, b, h, args, v, K))
 return dmp_strip(result, u)

def dmp_apply_pairs ( f , g , h , args , u , K ) : if ( not u ) : return dup_apply_pairs ( f , g , h , args , K ) ( n , m , v ) = ( len ( f ) , len ( g ) , ( u - 1 ) ) if ( n != m ) : if ( n > m ) : g = ( dmp_zeros ( ( n - m ) , v , K ) + g ) else : f = ( dmp_zeros ( ( m - n ) , v , K ) + f ) result = [ ] for ( a , b ) in zip ( f , g ) : result . append ( dmp_apply_pairs ( a , b , h , args , v , K ) ) return dmp_strip ( result , u )
apply h to pairs of coefficients of f and g .