On Saturday, 5 September 2015 21:00:47 UTC+2, Aaron Meurer wrote:
>
>
> I don't think you need traversal. You just need to rebuild the 
> expression from the bottom up with the remaining args (remember that 
> expr == expr.func(*expr.args)). 
>
>
That still requires unpacking the expression tree.

An API like *expr.args[2] = new_third_arg_value* would violate the object's 
immutability.

Mathematica's expression trees are not immutable. It has some kind of 
mechanism by which any modification gets notified to the reference counter, 
which updates all usage instances.
 

> It would probably be useful to have some utilities functions for 
> dealing with tuples like (1, 0) meaning expr.args[1].args[0]. 
>

 Maybe *expr.args[1, 2] *?

Some extensions like those used by Mathematica?
Cfr: https://reference.wolfram.com/language/tutorial/PartsOfExpressions.html

That is:

   - Range: *expr.args[0, :3] ==>* picks 1st arg, then returns its first 3 
   subargs.
   - Groups: *expr.args[(1, 3)]* ==> picks 2nd and 4th args.

What about if I add such options on this line:

https://github.com/sympy/sympy/blob/d29f329b38cf3722518b14c0e131b0b1f36b9e37/sympy/core/basic.py#L653


Is it reasonable?

-- 
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/d7df86c6-d9ba-4ade-900d-d9eb25006d3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to