Question: How to check for power and count for 1 power to reduce duplication?

I can't find how to use Maple structured type, to check for say sin(x) and say sin(x)^2 without having to duplicate the code and make a structured type for each of the two cases. An example will explain.

I need to check if expression is of this form   m*sin(anything)^n*cos(anything)^r  Where in this example below, m,n,r can be integer or rational.     

The problem is that 'specfunc'(sin)^Or(integer,rational) will not match sin(x) but will only match if sin(x) is raised to an actual power different from default 1.

So I have to duplicate the check below, by writing Or('specfunc'(sin),'specfunc'(sin)^Or(integer,rational) and the same for cos(x). I am trying to avoid all this duplication, because as the structured type becomes more involved, it will hard to read and work with like this.

Is there a way to eliminate this? In Mathematica for example, this is done using the pattern   x_. where the little dot at the end there, allows for zero of more. So for the above, it will be  Sin[x_]^n_. and this will match Sin[anything] and also match Sin[anything]^2 

I know it is possible to use patmatch in Maple to do this, but is it possible without using pathmatch and just using structured types? as I am trying to do everything without having to use patmatch now.

my_type:=''`*`'( { Or('specfunc'(sin),'specfunc'(sin)^Or(integer,rational)),


btw, the help page for structured type mentiones zero or more occurances of but do not know how to do this for the above example


Please Wait...