%mathpiper,def="IsMonomial"

//Retract("CanBeMonomial",*);
//Retract("IsMonomial",*);

10 # CanBeMonomial(_expr)_(Type(expr)="UniVariate") <-- False;

10 # CanBeMonomial(_expr)<--Not (HasFunc(expr,ToAtom("+")) Or HasFunc(expr,ToAtom("-")));

10 # IsMonomial(expr_CanBeMonomial) <-- 
[
    Local(r);
    If( IsRationalFunction(expr),
        r := (VarList(Denominator(expr)) = {}),
        r := True
    );
];

15 # IsMonomial(_expr) <-- False;

%/mathpiper








%mathpiper_docs,name="IsMonomial",categories="User Functions;Predicates"
*CMD IsMonomial --- determine if {expr} is a Monomial
*STD
*CALL
	IsMonomial(expr)

*PARMS
{expr} -- an expression

*DESC
This function returns {True} if {expr} satisfies the definition of a {Monomial}.
Otherwise, {False}.
A {Monomial} is defined to be a single term, consisting of a product of numbers
and variables.

*E.G.
In> IsMonomial(24)
Result: True

In> IsMonomial(24*a*x^2*y^3)
Result: True

In> IsMonomial(24*a*x^2*y^3/15)
Result: True

In> IsMonomial(24*a*x^2*y^3/15+1)
Result: False
    
%/mathpiper_docs
