Passing functions as parameters



The apply method has problems too:

  (%i12) testfun(f, a) := apply(f,[a]) $
  (%i13) testfun(a,1);
   apply: found a evaluates to 1 where a function was expected.

Once again you are stuck with using goofy and difficult to read names and hoping for the best:

 (%i16) testfun(%f, %x) := apply(%f,[%x]) $

 (%i17) testfun(a,1);
 (%o17) a(1)

If the lambda form method appeals to you, but lambda is too verbose, try:

  http://www.math.utexas.edu/pipermail/maxima/2012/028437.html

Or you can give up and pass a formula and variable instead of a function.


--Barton