Question regarding passing functions as arguments



Thanks giovanni.  I had made a mistake in defining my function with [] rather than ().  Now it works.  I also tried to verify with a simple example 
         g(f,x):=block([h:f],diff(h(x),x));
         h(t):=t^3 + t;
 and it gives me result as expected.
      (%i24)                 g(h,t);
                                              2
(%o24)                             3 t  + 1   

  I think I can pass function as arguments rather than passing expression that defines the function.


Thanks for the link.

Ram

 -------------- Original message ----------------------
From: giovanni gherdovich <g_gherdovich at yahoo.it>
> Hello Ram,
> 
> > [...]
> > 
> > listarray(t);
> > 
> > f(x):=(x-3)*(x-6)*(x-9);
> >  
> > for i:1 thru nm4 do
> > 
> >  [...]
> 
> In this script you specify the function, but you
> don't know how to pass the function as an argument
> to a more general script.
> 
> I had the same problem, and after few experiment I
> found a way that worked for me: you must pass
> the expression af your function to the script, than
> you have to define the function inside the script
> from this expression. I mean:
> 
> compCoef(input_expression):= block (
> ...
> define(f(x),input_expression),
> 
> /* now you can work with f(x) */
> ...)$
> 
> Then you can pass to the script expressions like
> (x-3)*(x-6)*(x-9), or whatever you want.
> 
> You can write comments in the script using slash and
> star, like 
> /* I'm a comment */
> 
> Hope to help.
> I found useful these tutorials to programming in 
> Maxima:
> http://maxima.sourceforge.net/docs/intromax/intromax.html#tth_sEc7
> http://maxima.sourceforge.net/docs/tutorial/en/gaertner-tutorial-revision/Pages/
> Programming0001.htm
> 
> Giovanni Gherdovich
> 
> 
> 	
>  p4.vert.ukl.yahoo.com uncompressed/chunked Thu Aug 31 00:13:36 GMT 2006 
> 	
> 		
> ___________________________________ 
> Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
> http://mail.yahoo.it