On Sat, Mar 14, 2009 at 11:27 AM, Carl Witty <carl.wi...@gmail.com> wrote: > > On Sat, Mar 14, 2009 at 10:49 AM, William Stein <wst...@gmail.com> wrote: >> On Sat, Mar 14, 2009 at 10:29 AM, Carl Witty <carl.wi...@gmail.com> wrote: >>> 1) Piecewise functions: >>> With my initial patch, >>> sage: f = Piecewise([[(-1,1),1/2+x-x^3]]) >>> doesn't work (that is, you get deprecation errors when you call f); >>> Burcin suggested an optional variable argument to Piecewise, so you >>> could type this instead: >>> sage: f = Piecewise([[(-1,1),1/2+x-x^3]], x) >> >> This seems reasonable, maybe. Also >> >> sage: f(x) = Piecewise([[(-1,1),1/2+x-x^3]]) >> >> should work. >> >> Also "Piecewise" suggests "piecewise *function*" so maybe they *have* >> to be a function? It's not a peicewise symbolic expression! > > Certainly functions are allowed there
No, I meant that the output of Piecewise is supposed to be a "piecewise *function*", so > sage: f = Piecewise([[(-1,1),1/2+x-x^3]]) this should be a ValueError. > to > sage: f = Piecewise([[(-1,1),(1/2+x-x^3).function(x)]]) > but that's quite a syntactic overhead, especially if you've got lots > of functions in the list. I like Burcin's shortcut. > > sage: f(x) = Piecewise([[(-1,1),1/2+x-x^3]]) > > is tricky; at least with the current implementation, that means that > Piecewise(...) (with expressions, not functions) has to be allowable > as a symbolic expression. Which is weird... > I was going to put the deprecation warning > for this case in the piecewise constructor (so you get the deprecation > warning when you make the piecewise function, not when you call it); > allowing f(x) = Piecewise(...) breaks that, as well. So how strongly > do you feel about f(x) = Piecewise(...)? I definitely like that. Honestly, I wouldn't mine Piecewise working like it used to and figure out how to make a function from each input... since Piecewise makes no sense if each expression isn't a function. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---