This is what you really want to do (use a *callable* symbolic expression):
sage: def g(a,b,c): f(x,y) = a*x^2 + b*y + c return f ....: sage: h = g(1,2,3) sage: h (x, y) |--> 2*y + x^2 + 3 sage: h(2,3) 13 On 8/27/07, Justin Walker <[EMAIL PROTECTED]> wrote: > > Hi, all, > > I want to create a "function" within a function, and return it as the value > of the latter function, something along the lines of: > > def g(a,b,c): > var('x y') > f = a*x^2 + b*y + c > return f > > This works, almost. I have to invoke the return value as a function > returning a function: > > sage: f = g(1,2,3) > sage: f(0) > 2*y + 3 > sage: f(0)(1) > 5 > > I can't treat it as a function of two variables: > > sage: f(0,1) > --------------------------------------------------------------------------- > <type 'exceptions.TypeError'> Traceback (most recent call last) > > /SandBox/Justin/sb/Sage/Code/<ipython console> in <module>() > > <type 'exceptions.TypeError'>: __call__() takes at most 2 arguments (3 given) > sage: > > It's not clear from the doc what should happen, but this is a bit of a > surprise. > > Justin > > -- > Justin C. Walker, Curmudgeon-At-Large > Institute for the Enhancement of the Director's Income > -------- > When LuteFisk is outlawed, > Only outlaws will have LuteFisk > -------- > > > > -- William Stein Associate Professor of Mathematics University of Washington http://www.williamstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---