Hi,

in Mathematica one can access the expression tree by the [[ ]] operator:


In[1]:= e = x*y + z                                                         
    

Out[1]= x y + z

In[2]:= e[[1]]                                                             
     

Out[2]= x y

In[3]:= e[[1, 1]]                                                           
    

Out[3]= x


Now one could change the *x* for a *q*:


In[4]:= e[[1, 1]] = q                                                       
    

Out[4]= q

In[5]:= e                                                                   
    

Out[5]= q y + z                                           


This works by replacing a part in the expression tree (position [[1, 1]]), 
there is *no* pattern matching.

I was wondering, is there something like that in SymPy?

Maybe, instead of accessing *e.args[0].args[0]* (Mathematica's arrays are 
1-starting), have some 



*e.<some method>(0, 0)*and

*new_e = e.<some other method>(<new value>, 0, 0)*

Is there some easy way to avoid writing a traversal function?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/8fc479d2-8131-4c01-9ad3-5618c52588e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to