Interpolation function



[Daniel Lakeland , Fri, 9 Dec 2005 14:34:47 -0800]:
> I was disappointed when I tried to do something like this and found
> that maxima uses dynamic scope instead of building a closure. I was
> looking to write a function which takes data as an argument and
> returns a function that does the interpolation, this is a standard
> trick in LISP, but without closures it was not trivial.

I find the following idiom to be easy to use and reliable:

    (%i1) make_inc(x) := buildq([x], lambda([y], x+y)) $
    
    (%i2) f : make_inc(2+3);
    
    (%o2)                         LAMBDA([y], 5 + y)
    (%i3) f(3);
    
    (%o3)                                  8

Regards,

Albert.