Re: Re: [Maxima] Some Context Probleme ?



Marc GILG <M.Gilg@univ-mulhouse.fr> writes:

> Yes that's the problem. Where can I get the solution to this ?
> Le mar 10/12/2002 à 18:35, go_furuya@infoseek.jp a écrit :
> > This is the same problem as Aug 27 :RE puzzle with pattern matching.(MAXIMA ML)

Two solutions were presented but nobody else joined the discussion, so
things were left undecided and not fixed.  Your example works with my
current maxima image (which contains one of the proposed bug fixes ;-)

You might however prefer not to use pattern matching at all and to
proceed like this:

/* linfrob.mac */

iflplusmap(fun,exp) :=
  if not atom(exp) and inpart(exp,0)="+"
    then map(fun,exp)
    else apply(fun,[exp])$

curried(f,x) :=
  block([z:?gensym()],buildq([f,x,z],lambda([z],apply(f,[x,z]))))$

linfrob(f,exp) :=
  subst(lambda([x,y],
          iflplusmap(curried(f,x),y)),
    f,exp)$

/* linfrob.mac ends here */


(C1) load("~/linfrob.mac");

(D1) 				 ~/linfrob.mac
(C2) trace(iflplusmap);

(D2) 				 [iflplusmap]
(C3) linfrob(g,g(u,g(v,x+y+z)+1));

1 Enter iflplusmap [LAMBDA([G7895], APPLY(g, [v, G7895])), z + y + x]
1 Exit  iflplusmap g(v, z) + g(v, y) + g(v, x)
1 Enter iflplusmap [LAMBDA([G7896], APPLY(g, [u, G7896])), 

					       g(v, z) + g(v, y) + g(v, x) + 1]
1 Exit  iflplusmap g(u, g(v, z)) + g(u, g(v, y)) + g(u, g(v, x)) + g(u, 1)
(D3) 	    g(u, g(v, z)) + g(u, g(v, y)) + g(u, g(v, x)) + g(u, 1)
(C4) 

This technique of substituting a lambda expression for the leading
operator is extensively used in ASB's declin.mac, which implements the
converse thing (i.e., contracting by linearity in selected arguments).
Try `demo("declin");' and see `maxima/share/misc/declin.usg'.

BTW, in order to complete or correct the history section of
`genut.mac' I'd be very delighted to know more of ASB's identity.
Anyone?

Wolfgang
-- 
wjenkner@inode.at