A inconsistency with maplist (or with my understanding of maplist).



Mark,

Maxima regards the first expression as "/"(x,x-2) and the second as
"+"(x/x-2,1).  Maplist iterates over the arguments of the top-level
operator.

If you want to work on additive terms -- that is, if you want an implicit
"+" operator at the top level -- you might want to do something like this:

   map_additive_terms(f,ex) := if mapatom(f) or op(f)#"+" then [f(ex)] else
maplist(f,ex)$

The following function might be useful for showing the structure of
expressions:

   show_structure(ex):=if mapatom(ex) then ex else
apply(concat(\<\<,op(ex),\>\>),maplist(show_structure,ex));

Now:

(%i21) show_structure(x/y-z);
(%o21) <<+>>(<</>>(x,y),<<->>(z))

Maxima's internal representation is slightly different, and you can access
that by setting inflag:true.

(%i22) show_structure(x/y-z),inflag:true;
(%o22) <<+>>(<<*>>(x,<<^>>(y,-1)),<<*>>(-1,z))

I trust that makes things clearer.

                   -s



On Mon, Jul 8, 2013 at 10:17 AM, Mark Skilbeck <m at iammark.us> wrote:

> It really is a problem with my understanding of maplist as I haven't any.
>
> The following quickly displays my troubles:
>
> (%i188) maplist(identity, x/(x-2));
> (%o188) [x,x-2]
> (%i189) maplist(identity, x/(x-2)+1);
> (%o189) [x/(x-2),1]
>
> My initial belief was that maplist would map over the "terms" of the
> second input (the expression x/(x-2), etc.), although maybe my understand
> of what constitutes a "term" is wrong; however, the above doesn't play
> ball! I would've thought in the first example that I would
> receive [x/(x-2)].
>
> What am I missing?
>
> Cheers,
> Mark.
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>