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; my initial patch changed doctests like sage: f = Piecewise([[(-1,1),1/2+x-x^3]]) 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. 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(...)? Carl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---