Burcin Erocal wrote: > On Fri, 07 Nov 2008 06:40:17 -0600 > Jason Grout <[EMAIL PROTECTED]> wrote: > >> Burcin Erocal wrote: >>> On Fri, 7 Nov 2008 03:26:35 -0800 >>> "Mike Hansen" <[EMAIL PROTECTED]> wrote: >>> >>>> On Fri, Nov 7, 2008 at 3:14 AM, Jason Grout >>>> <[EMAIL PROTECTED]> wrote: >>>>>> plot( f(x=5), (y, -10,10)) >>>>>> >>>>>> plot( f(x=5,y=y), (y, -10,10)) >>>>>> >>>>>> plot( f(5,None), (y, -10,10)) >>>>>> >>>>>> plot( f(5,y), (y, -10,10)) >>>>>> >>>>>> g(y) = f(5,y) >>>>>> plot(g, (y, -10,10)) >>>>>> That last one seemed too verbose >>>>> I guess you could also do: >>>>> >>>>> plot( lambda y: f(5,y), (y, -10,10)) >>>>> >>>>> but then you give up things like fast_float. >>>> You didn't mention >>>> >>>> plot(f(5,y).function(y), (y, -10,10)) >>>> >>>> which is the one that'd be compatible with non-callable >>>> expressions. >>> If symbolic expressions cease to be callable, plot would need to be >>> changed to handle these cases: >>> >>> sage: plot( x^2 ) >>> >>> This seems plausible, since at the moment we allow >>> >>> sage: plot( sin ) >>> >>> for usability. >>> >>> >>> Going back to your example, f(5,y) would just return a symbolic >>> expression, so >>> >>> sage: f(x,y)=2*x+3*y >>> sage: plot( f(5,y), (y, -10,10)) >>> >>> would be equivalent to >>> >>> sage: plot( 10+3*y, (y, -10,10)) >>> >>> which would just work. >>> >>> >>> The current syntax allows this: >>> >>> sage: f(x,y) = a*x + b*y >>> sage: f(5) >>> b*y + 5*a >>> sage: f(5)(5) >>> b*y + 25 >>> >>> >>> I think the last line should be a syntax error. >> >> I agree, since f was explicitly defined with variables x and y. >> >> f(5) should return a function g(y) = b*y+5*a >> >> I think this could be easily changed (just return a function that has >> explicit variables, rather than just a symbolic expression). > > I would still like to check that the length of the arguments match, and > raise an error if they don't. So, continuing the above example, > > sage: f(5) > > should raise an error. > > It might be better if > > sage: f(5, None) > > or > > sage: f(5,y) > > returned the function g(y) = b*y+5*a. > >
I agree with both of those alternatives, and agree that it would be better to insist that f take two arguments. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@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-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---