Hi Aaron,


I find srepr in SymPy a powerful tool and can be applied in many ways to 
compare and traverse expressions and subexpressions in a tree.


>>> x = Symbol('x')
>>> a = Symbol('a')
>>> b = Symbol('b')
>>> m = Symbol('m')
>>> expr = (a + b*x)**m
>>> srepr(expr)
"Pow(Add(Symbol('a'), Mul(Symbol('b'), Symbol('x'))), Symbol('m'))"
>>> expr.args
(Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True))), Symbol('m'))
>>> expr.args[1]
Symbol('m')
>>> expr.args[0]
Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0]
Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0].args
(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0].args[1]
Mul(Symbol('b'), Symbol('x', positive=True))


On Saturday, March 18, 2017 at 3:18:57 AM UTC+5:30, Richard Fateman wrote:
>
> .. I said
>
> ....  you could snarf down huge
>> piles of "application" code -- at least at some superficial level --
>> and then cut in the sympy alternatives as necessary for the
>> application,.
>>
>>
> which is what Mathics might do, if my understanding of the
> documentation is correct.  I have not tried it.
>
> Oh, since Mathics pattern matcher looks like it is (intending to)
> implement Mathematica, including backtracking, it may be
> susceptible to being very slow for patterns involving, for example,
> +  and * .
> RJF 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/7b5df0cd-6022-4657-976c-8772ab1629f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to