On Sat, Apr 03, 2010 at 10:54:52AM -0700, Robert Dodier wrote: > On Apr 2, 12:14 pm, Jason Grout <jason-s...@creativetrax.com> wrote: > > On 04/02/2010 12:47 PM, Franco Saliola wrote: > > > > Here is a very simple implementation of SymbolicVariables. > > > > > class SymbolicVariables(SageObject): > > > def __init__(self, prefix='x'): > > > self._prefix = prefix > > > def __getitem__(self, i): > > > return var("%s%s"%(self._prefix, i)) > > > This has come up several times before on sage-devel, and I've always > > liked it. For example, Nathann Cohen brought this up when he was first > > integrating the linear programming stuff. I believe Robert Bradshaw > > suggested this "indexing creates a variable" approach a while ago too. > > > > When/if we wrap pynac vectors/matrices, though, or have "symbolic vector > > variables", we might have to be careful about how we treat the > > __getitem__ function. I think in your case, where you explicitly are > > creating x with the understanding that indexing x creates new variables, > > things would be fine, though. > > Not that it matters, but creating new symbols for indexed > variables seems to have some potential for unexpected behavior, > aside from cluttering the namespace. > > Another approach is to represent an indexed variable as a > symbolic expression the same as an unevaluated function call, > but with an extra flag which essentially just shows it's > a subscripted expression instead of a function call. > (There isn't any real conceptual difference, right? > A subscripted variable is just a function on some countable > set.)
+1 Just: why countable? Well, yeah, there are only countably objects that can be represented on a computer. I guess all I want to point out is that such subscripted variables would be useful with all sorts of subscripts (trees, graphs, groups, ...), and not just integers. > There is an existing program which uses this scheme, > although it doesn't matter which one it is, so I won't > bother to mention it. More than one :-) Cheers, Nicolas -- Nicolas M. Thiéry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe, reply using "remove me" as the subject.