polynom -> list



Well, actually as Richard Fateman mentioned in his message, you do have to
do some parameter testing. As in

pargs(x):=if atom(x) or length(x)=0 or op(x)#"+" then x else args(x);

Mind you, Richard's suggestion may be more elegant:

pargs(x):=if atom(x) or length(x)=0 or op(x)#"+" then x else
substpart("[",x,0);

By 'elegant' I really mean efficient, something that will work well even on
very large polynomials. (I don't know if it's args() or substpart() that
does a more efficient job.)

Of course if you're only going to process relatively simple expressions, the
makelist() approach will work, too.


Viktor


 

-----Original Message-----
From: maxima-admin@math.utexas.edu [mailto:maxima-admin at math] On
Behalf Of Frank Thieme
Sent: Saturday, December 18, 2004 5:35 PM
To: Maxima@math.utexas.edu
Subject: RE: [Maxima] polynom -> list

On Sam, 2004-12-18 at 17:24 -0500, Viktor T. Toth wrote:
> Try args(exp). It's a little bit more efficient. E.g.,
> 
> (%i1) exp:a*b+c^d;
>                                     d
> (%o1)                              c  + a b
> (%i2) args(exp);
>                                      d
> (%o2)                              [c , a b]

yeah, but args(x) does not work, but my solution returns a [x].

thanks anyway...

_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima