Hi Simon,

On Mon, 25 Oct 2010 06:09:16 -0700 (PDT)
Simon King <simon.k...@uni-jena.de> wrote:

> On 25 Okt., 14:39, Burcin Erocal <bur...@erocal.org> wrote:
> > If we return an identity operator for these cases, how do you plan
> > to test for it in your code:
> 
> Something like this:
> 
> L = x.operands()
> if len(L)>1:
>     return x.operator()(*map(lambda ..., L))
> else:
>     try:
>         return x.operator()(round(L[0],...))
>     except TypeError:
>         return x

This initializes a list with a single element for objects which return
None for operator() now. IMHO, this approach is inefficient. In this
case, you should act on the object directly.


In any case, we should wrap the following ginac interfaces to provide a
better way of doing this:

 * A way to apply a function to the operands of an expression:

http://www.ginac.de/tutorial/Applying-a-function-on-subexpressions.html

 * or tree traversal:

http://www.ginac.de/tutorial/Visitors-and-tree-traversal.html


Cheers,
Burcin

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to