On Sun, Aug 2, 2009 at 2:00 PM, William Stein <wst...@gmail.com> wrote:

>
> On Sun, Aug 2, 2009 at 9:13 AM, Robert Dodier<robert.dod...@gmail.com>
> wrote:
> >
> > Robert Bradshaw wrote:
> >
> >> Sage lists are Python lists, which are very different than
> >> Mathematica lists.
> >
> > You say that as if it's a fact of geography which can't be changed.
> >
> >> to change all lists would be a massive (backwards-
> >> incompatible) change, as well as another step away from Python.
> >
> > Not exactly. At present something like 1 + [2, 3, 4, 5] causes Python
> > to cough up an error, right? So extending arithmetic operators to
> > lists wouldn't change the behavior of any existing Python program.
> > (I'm not worried that someone might have written a program which
> > requires an error to be triggered when number + list is encountered.)
>

I think Robert has a good point here: infix operations between numbers and
lists wouldn't break any Python code, because this kind of constructs are
not supported in pure Python. However, it could add a lot of readability and
programming easiness to Sage because a common task as a scientist is to
manipulate and transform a lot of data and (I think) the most basic
container to do that is a list.


> Unfortunately for your suggestion, arithmetic operators are methods of
> the objects.  To make "1 + [2,3,4,5]" and "[2,3,4,5] + 1" not raise an
> exception would require changing the Python interpreter itself, at the
> C level.


True, but I think it's possible to catch all this things with the preparser
and make them work as expected, as I suggested before.

Is it possible and worth the try? I would want to do it when I have some
spare time.

Carlos


> >
> > You could even pitch it in algebraic terms. The set of lists comprises
> > an ideal in the ring of ... well, of something. Maybe the ring of
> > all numbers and lists. Anyway maybe that would appeal to someone
> > with an algebraic state of mind.
> >
> >> Of course, we support all of this without numpy as well.
> >>
> >> sage: a0 = vector([1,2,3,4])
> >
> > That's not enough. Only vector + vector, scalar * vector, and
> > inner product are defined, right? I'm pretty sure users would
> > like to see vector * vector, vector ^ exponent, scalar / vector, etc.
> >
> > With all that said, Mathematica is more than a little confused
> > about lists --- there is no distinction between lists and sets, and
> > a matrix is just a list of lists. That's a mess, which Sage shouldn't
> > duplicate. But arithmetic on lists isn't confusing.
>
> Agreed. We definitely didn't duplicate that lack of structure in Sage.
>
> >
> > FWIW
> >
> > Robert Dodier
> >
> > >
> >
>
>
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to