# [Maxima] Arguments of operatorp

Richard Hennessy rich.hennessy at verizon.net
Tue Jun 19 12:50:09 CDT 2012

```There is a function scanex() in pw.mac.  It will walk an expression and
apply a function which you define to each part of the expression.  For
example.

(%i67) ex:gamma(diff(f(integrate(h(x)*x^2+y,x),x)))\$
(%i68) F(_e):=(L:[],scanex(lambda([x],if safe_op(x)#false then
L:endcons(safe_op(x),L)),_e),setify(L))\$
(%i68) F(ex);
(out68) {*, +, ^, f, h, del, derivative, gamma, integrate}

In this case the function applied is a lambda expression that just gathers a
list of operators it encounters. If you want to do something else with the
parts it may be possible to just change the lambda function.

HTH,

Rich

PS Here is scanex();

scanex(__f,__e):=
block
(
[inflag : true, _p],
if safe_op(__e) # false then
(
apply(__f, [__e]),
for _p in __e do (
if safe_op(_p) # false then
(
scanex(__f, _p),
apply(__f, [_p])
)
else
apply(__f, [_p])

)
)
else
apply(__f, [_p])

)\$

-----Original Message-----
From: Jérome Laurens
Sent: Tuesday, June 19, 2012 2:15 AM
To: maxima at math.utexas.edu
Subject: [Maxima] Arguments of operatorp

Hi list,

operatorp documentation is very short even on the web.

It seems that the second argument or operatorp is a string aka the name of
the operator
for example operatorp(a+b,"+") returns true
but I don't know how to recognize diff or integrate operators
for example operatorp(integrate(...),"integrate"),
operatorp(diff(...),"diff'), operatorp(diff(...),"derivative") both return
false.

Maybe this is intended behaviour but in that case, how would I walk an
expression to find the integrate and diff operators ?

TIA

_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

```