%mathpiper,def="xFactor"

//Retract("xFactor",*);

10 # xFactor( p_CanBeUni ) <-- FW(xFactors(p));


10 # xFactor( p_IsRationalFunction ) <--
[
    Local(fs,n,d);
    fs := xFactors( p );
    n  := FW(Numerator(fs));
    d  := FW(Denominator(fs));
    n/d;
];


10 # xFactor( L_IsList ) <-- 
[
    Local (result,x,f);
    result := {};
    ForEach(x,L)
    [
        f := xFactors(x);
        If( f = {}, f := 0, f := FW(f) );
        DestructiveAppend(result,f);
    ];
    result;
];



20 # xFactor( _expr ) <-- expr;

%/mathpiper