On Sat, 21 Mar 2009 03:02:57 -0700 Robert Bradshaw <rober...@math.washington.edu> wrote:
> > On Mar 21, 2009, at 2:01 AM, Craig Citro wrote: > > >> I think that better way is to use maxima commands op, args, length, > >> atomp > >> > > > > I think that for objects which come from Maxima, this is the right > > thing to do. However, not all symbolic objects in Sage are wrappers > > for Maxima objects -- in the case of expressions using pynac, the > > code above actually moves them over to Maxima (via strings and > > pexpect) and then ask for their length there (which probably > > ultimately uses the commands you mention). This is less than > > desirable, hence my claim that it was a terrible way to calculate > > the length. :) > > > > I think a first step might be to introduce a __len__ method for > > symbolic objects, but then, I'm not always sure what it should > > return. > > I would argue that this is a good reason not to implement it :). > Something like nops would be trivial to implement though, and > probably a good idea. > It's in pynac already: sage: var('x,y',ns=1) (x, y) sage: f = expand((1+x+1/y)^10) sage: f.nargs() 66 I could hook this up to __len__ as well, since __getitem__ lets you access parts of the expression. E.g., sage: f[0] x^10 sage: f[1] 10*x^9 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 URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---