green's functions, passing functions to a routine



On Sunday 07 September 2008 09:08:22 pm Stavros Macrakis wrote:
> 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)
>

> 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 

  Remembering that you said that before, I vetted my code yesterday for
  part and somehow missed it. In case of taking parts of a list, there
  is certainly no difference between the representations

> 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

  I noticed that the compiler takes unquoted functions to be global-varibles.

  Thanks once more for the advice. I just quoted the functions names
  and replaced   part by inpart in all my code and it still passes all tests.


  John