#NEWLINE# def dup_compose( f , g , K ) : #NEWLINE# #INDENT# '\n    Evaluate functional composition ``f(g)`` in ``K[x]``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, ZZ\n    >>> R, x = ring("x", ZZ)\n\n    >>> R.dup_compose(x**2 + x, x - 1)\n    x**2 - x\n\n    ' #NEWLINE# if ( len ( c ) <= 1 ) : #NEWLINE# #INDENT# return dup_strip ( [ dup_eval ( f , dup_LC ( g , K ) , K ) ] ) #NEWLINE# #UNINDENT# if ( not f ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# h = [ f [ 0 ] ] #NEWLINE# for c in f [ 1 : ] : #NEWLINE# #INDENT# h = dup_mul ( h , g , K ) #NEWLINE# h = dup_add_term ( h , c , 0 , K ) #NEWLINE# #UNINDENT# return h