Hi,
I get elements inside an expression as res=3*x*exp(x^2) by
res.operands() and res.operator().
So I catch 3 or x or exp(x^2) by res.operands()[0 or 1 or 2].
But how can I test that the first one is an Integer without error ?
The res._interger_() seems to accept to retract the expression 12345 to
the integer 12345,
but I get an error with a symbolic variable.
I want to climb in the expression trees and write recursive functions with :
def inside_expr (expr) :
if (expr is an atomic variable) :
do...
elif (expr is an atomic integer) :
do
elif ... rational number ...
elif ... float ...
elif # there is an operator and operand(s)
recall inside_expr...
Thanks again for a new little help.
F.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---