 <PRIVATE
 
 : (pgcd) ( b a y x -- a d )
-    dup V{ 0 } clone p= [
+    dup V{ 0 } p= [
         drop nip
     ] [
         [ nip ] [ p/mod ] 2bi

    dup 1 < [ drop 1 ] when
    [ over length + 0 pad-head pextend ] keep 1 + ;

: /-last ( seq seq -- a )
    #! divide the last two numbers in the sequences
    [ last ] bi@ / ;

: (p/mod) ( p p -- p p )
    2dup /-last

: 2ptrim ( p q -- p' q' ) [ ptrim ] bi@ ;
: p+ ( p q -- r ) pextend v+ ;
: p- ( p q -- r ) pextend v- ;
ALIAS: n*p n*v

: pextend-conv ( p q -- p' q' )
    2dup [ length ] bi@ + 1 - 2pad-tail ;

: p* ( p q -- r )
    2unempty pextend-conv 
    [ drop length [ iota ] keep ]
    [ nip <reversed> ]
    [ drop ] 2tri
    '[ _ _ <slice> _ v* sum ] map reverse ;

: p-sq ( p -- p^2 ) dup p* ; inline

ERROR: negative-power-polynomial p n ;

