listofops?



On Oct. 20, Stavros Makrakis wrote:

   > Something like this?:
   >
   > declare(union,nary)$
   > listofops(expr) := block([inflag:true], if mapatom(expr) then {} else
   > adjoin(op(expr),xreduce(union,maplist(listofops,expr))))$
   >
   > inflag:true uses the internal form for efficiency; be aware that
   > listofops(-a/b) => {"*","^"} (from  (-1)*a*b^(-1)) instead of {"-","/"}
   >

Actually, I asked for the wrong thing. I should have asked for
something to detect the presence, in an expression, of one
of Maxima's special functions (true/false).

I found funp, funp1, funp2 in ...share/fourie.mac, which does
the job to define spfunp (expr) ;  see below:

-----------------------------------------
(%i1) load(temp);
(%o1)                          c:/work2/temp.mac

(%i2) spfunp (bessel_y(2,x));
(%o2)                                true

(%i3) spfunp (x);
(%o3)                                false
(%i4) spfunp (x*bessel_y(2,x) + bessel_j(0,x));
(%o4)                                true

--------------------------------------------------
/* temp.mac
    oct. 20, 2011
    code spfunp to detect special functions:
    return true is any are found
    return false otherwise
    */


  /* funp1: code from ....share/calculus/fourie.mac  */

  funp1(fun,exp):=block([inflag],inflag:true,
       if mapatom(exp) then false
      else (if inpart(exp,0) = fun then true
      else member(true,maplist(lambda([q],funp1(fun,q)),exp))))$


 spfunp (expr) :=
    block ([spfun,  spf:false],

        for spfun in
           [bessel_j,bessel_y,bessel_i,bessel_k,
            hankel_1,hankel_2,struve_h,struve_l,
            assoc_legendre_p,assoc_legendre_q,
             %f,gamma,gammagreek,gammaincomplete,
            hypergeometric,slommel,%m,%w,erfc,
            expintegral_e,expintegral_e1,
            expintegral_ei,expintegral_li,
            expintegral_si,expintegral_ci,
            expintegral_shi,expintegral_chi,
             kelliptic,parabolic_cylinder_d]  do

             if funp1 (spfun,expr) then (
                  spf:true,
                  return()),
        spf)$

-------------------------------------------------