On 11/5/12 3:52 PM, Michael Orlitzky wrote:
On 11/05/12 12:40, Jason Grout wrote:
On 11/4/12 11:14 AM, Michael Orlitzky wrote:
I'm playing around with different ways to create collections of symbolic
variables. I though it would be nice to be able to chain subscripts,
e.g.,

    sage: x[1][2]
    x12
    sage: latex(x[1][2])
    x_{1}_{2}

Why not do:

x[1,2]

to save typing and make it more like matrices?

I know this doesn't exactly answer your original question, but I think
the notation would be a bit nicer...


I was preparing for bad news re: indexing expressions, so I went back to
work on a class, an instance of which we could return from e.g.
SR.symbols(). It supports a(0,1), a[0,1], a[1:5], a(4, slice(2,5)), and
every other notation I could think of.

I've got it in my init.sage right now:

http://michael.orlitzky.com/git/?p=sage.git;a=blob;f=mjo/symbol_sequence.py;h=7f6c9db7622a2e360a964dfda7cd721c01f885f9;hb=HEAD

I'll open a ticket eventually. There are examples of every usage in the
docstring -- if anyone has a pet notation, please take a look.

Very nice!

In the spirit of Python [1], "There should be one-- and preferably only one --obvious way to do it.", may I suggest that you pick one indexing convention (e.g., round or square brackets) and use that? I'd suggest using square brackets since that is consistent with other indexing notation in python/Sage.

I really like how you can do a[0,2:5] and get back the relevant variables.

Thanks,

Jason


[1] do: "import this" at the sage (or python) command line


--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
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.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.


Reply via email to