#9329: Improve documentation of how to access parts of the expression tree of a
symbolic expression
-------------------------------+--------------------------------------------
       Reporter:  kcrisman     |         Owner:  burcin  
           Type:  enhancement  |        Status:  new     
       Priority:  major        |     Milestone:  sage-5.6
      Component:  symbolics    |    Resolution:          
       Keywords:               |   Work issues:          
Report Upstream:  N/A          |     Reviewers:          
        Authors:               |     Merged in:          
   Dependencies:               |      Stopgaps:          
-------------------------------+--------------------------------------------

Comment (by kcrisman):

 Resurrecting the original idea because I want this for my discrete math
 class in a couple days and realize that even having a very basic example
 of how to use `Converter` to make an expression tree - say one I could
 plot! - would be really useful.  Right now I'm stuck with Jason's idea,
 which works but perhaps isn't as "Sage-ic".
 {{{
 sage: from sage.symbolic.random_tests import random_expr
 sage: S = random_expr(20,nvars=2)
 sage: S
 sinh_integral(-sec(-4*abs(e))/((kronecker_delta(e, v1) -
 52)*arctan(elliptic_kc(-2) - 2)))
 sage: def tree(expr):
 ....:     if expr.operator() is None:
 ....:         return expr
 ....:     else:
 ....:         return [expr.operator()]+map(tree,expr.operands())
 ....:
 sage: tree(S)
 [sinh_integral, [<built-in function mul>, [<built-in function pow>,
 [<built-in function add>, [kronecker_delta, [exp, 1], v1], -52], -1],
 [<built-in function pow>, [arctan, [<built-in function add>, [elliptic_kc,
 -2], -2]], -1], [sec, [<built-in function mul>, [abs, [exp, 1]], -4]],
 -1]]
 }}}
 I'm realizing it might even be useful to have a (binary) tree returned
 from a list of lists... but that wouldn't be here.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9329#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to