On Oct 24, 12:34 pm, Simon King <[email protected]> wrote:
> I guess it would be needed to define a recursive function for that
> purpose, using operator and operands of a symbolic expression. Such
> as:
>
> sage: def symround(x, ndigits=0):
> ....:     if hasattr(x,'operator') and x.operator():
> ....:         return x.operator()(*map(lambda
> y:symround(y,ndigits=ndigits), x.operands()))
> ....:     try:
> ....:         return round(x,ndigits=ndigits)
> ....:     except TypeError:
> ....:         return x

Thank you Simon!

It resolves my problem, and the efficiency is not an issue.

It just has a minor bug when the operator has more than two operands,
like x+y+z, but I'll try to fix it as I got the picture now.

Thanks,
Cristóvão Sousa

-- 
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-support
URL: http://www.sagemath.org

Reply via email to