teste

COEF_STRG

  • A non-commutative polynomial is sum of summands where each summand is a multiple of a monomial by a rational number. This  routine produces the coeffient of a summand written as a string.

 

gap>COEF_STRG("(2)*U*V");
(2)
gap>

COEF_STRG:=function(mon)
local pos;
pos:=Position(mon, '(');
if pos in Integers and IsDigitChar(mon[pos+1])=true or mon[pos+1] = '-' then
    return mon{[Position(mon, '(') .. Position(mon, ')')]};
else
    return "(1)";
fi;
end;