[Maxima] green's functions, passing functions to a routine
macrakis at alum.mit.edu
Sun Sep 7 23:08:22 CDT 2008
On Sun, Sep 7, 2008 at 11:59 PM, John Lapeyre <pdl at johnlapeyre.com> wrote:
> ...the generic problem of having v = [a,b,c] and needing to call a
> function that wants this: func(expr,a,b,c)
> lpart(m,v) := apply(part,cons(m,v));
so that lpart(expr,[i,j]) is the same as part(expr,i,j)
Not pretty, but I think that's what you have to do
I don't like it because it probably copies expr which may be large.
?? Why would it copy expr? On the other hand, if you care about efficiency,
you should *never* use part, and always use inpart (or set inflag:true).
Otherwise, every single time you call part, it reformats the expression from
the internal form e.g. "*"(-1,a,"^"(b,-1)) to the external form
"-"("/"(a,b)), performing a complete copy top-to-bottom even if the internal
form is the same as the external form.
By the way, when you *do* use functions in non-functional position, it is
good practice to quote them so that they don't inadvertently use a variable
binding that is lying around, e.g. apply('part,...) rather than
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Maxima