listofops?



union nary is necesary to get xreduce(union,[]) to return {}.  Barton and I
will add it to the set package -- it should be standard.

On Thu, Oct 20, 2011 at 18:25, Edwin Woollett <woollett at charter.net> wrote:

> On Oct. 20, Dieter Kaiser wrote:
> -----------
>
>  > Maxima has the Lisp function isinop. I have extended this function some
>  > times ago to return not only true and false, but a whole expression.
>  > With this function the following is possible:
>  >
>  > (%i1) expr:abs(x)+bessel_y(1,y)+**struve_h(0,z)+'integrate(f(x),**x);
>  > (%o1) 'integrate(f(x),x)+abs(x)+**bessel_y(1,y)+struve_h(0,z)
>  >
>  > (%i2) ?isinop(expr,abs);
>  > (%o2) abs(x)
>  >
>  > (%i3) ?isinop(expr,struve_h);
>  > (%o3) struve_h(0,z)
> [snip]
>
>  >
>  >
>  > If the operator is present, the whole expression is returned. This
>  > functions checks only for the first appearance of the operator. I think
>  > it is a nice function which we might add for the Maxima user.
> -----------
> Thanks for the information about this Lisp function.
> With the code which uses ?isinop
> instead of funp1:
> ----
> 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 ?isinop(expr,spfun) # false then (
>                 spf:true,
>                 return()),
>       spf)$
> ---------------
> I get same answers as before:
> (%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
> (%i5) expr:abs(x)+bessel_y(1,y)+**struve_h(0,z)+'integrate(f(x),**x)$
> (%i6) spfunp(expr);
> (%o6)                                true
> ------------------------------**-------
>
> On Oct. 20, Stavros Makrakis wrote:
>
>  The code below [referring to my funp1 code]
>>
>> is much less efficient than using listofops and
>> intersecting with whatever list of special functions
>>  you like.
>>
> ---------------------
> I have used the following approach with your
> listofops function, but there is probably a
> better arrangement?
> ------------------------------**------
>
> declare(union,nary)$
>
>  listofops(expr) := block([inflag:true], if mapatom(expr) then {} else
>        adjoin(op(expr),xreduce(union,**maplist(listofops,expr))))$
>
>  spfunp (eexpr) :=
>   (if length ( intersect (listofops (eexpr),
>
>                    {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})) > 0 then
>                        true
>    else false)$
> ------------------------------**-------
> which produces the same output as before.
>
> Not clear to me what effects the union,nary
> declaration would have on any other code
> in the same session?
>
> Ted
>
>
>
>