def dmp_list_terms(f, u, K, order=None):
 def sort(terms, O):
  return sorted(terms, key=(lambda term: O(term[0])), reverse=True)
 terms = _rec_list_terms(f, u, ())
 if (not terms):
  return [(((0,) * (u + 1)), K.zero)]
 if (order is None):
  return terms
 else:
  return sort(terms, monomial_key(order))

def dmp_list_terms ( f , u , K , order = None ) : def sort ( terms , O ) : return sorted ( terms , key = ( lambda term : O ( term [ 0 ] ) ) , reverse = True ) terms = _rec_list_terms ( f , u , ( ) ) if ( not terms ) : return [ ( ( ( 0 , ) * ( u + 1 ) ) , K . zero ) ] if ( order is None ) : return terms else : return sort ( terms , monomial_key ( order ) )
list all non-zero terms from f in the given order order .