Javier, Maxima parses ''f(x) as (''f)(x), not as ''(f(x)), which will do
what you want.
But I still recommend using define(A(...),B) rather than A(...):=''(B).
I recommend avoiding the '' operator for several reasons:
- Read-time evaluation is confusing and weird. Consider for example:
(%i36) [print(4),''(print(3))];
3
4
(%o36) [4,3]
or
(%i41) x:1$
(%i42) [''x,x,''(x:x+1),x:x+1,''x];
(%o42) [1,2,2,3,2]
- Read-time evaluation doesn't (can't!) respect scope rules:
block([x],''x) uses the global x, not the local x.
- '' cannot be used to create new function bodies within programs,
making interactive programming and function definition inconsistent.
- When reviewing code, it is hard to tell the difference between '' (two
single quotes) and " (one double quote).
Of course, old-time Lisp hackers like me love all these crazy different
evaluation times (read time, load time, compilation time, macro expansion
time, execution time...), but I don't think we should impose this
complexity on straightforward mathematical usage of Maxima.
-s
On Wed, Mar 14, 2012 at 08:09, Javier Arantegui
<javier.arantegui at gmail.com>wrote:
> Hello!
>
> On Wed, Mar 14, 2012 at 10:05 AM, Mike Valenzuela
> <mickle.mouse at gmail.com> wrote:
> > (%i1) f(x) := expand( x*(x+1) );
> > (%o1) f(x) := expand(x (x + 1))
> >
> > (%i2) g(x) := ''( expand( x*(x+1) ) )
> > (%o2) g(x) := x^2 + x
>
> But:
>
> (%i6) z=x+y;
> (%o6) z=y+x
>
> (%i8) f(x,y):=''rhs(%o6);
> (%o8) f(x,y):=rhs(%o6)
>
> (%i9) f(1,2);
> (%o9) y+x
>
> And:
>
> (%i10) define(g(x,y),rhs(%o6));
> (%o10) g(x,y):=y+x
>
> (%i11) g(1,2);
> (%o11) 3
>
> Javier
>
>
>
> --
> Lee mi blog: "Un peque?o paso para Neil" http://up3n.wordpress.com/
> ?Ahora tambi?n en Twitter! http://twitter.com/javierarantegui
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>