[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-11 Thread Harald Schilly
the int->integer replacement is done by a preparser. if you turn it off, sage is "pure" python only. the list is a pure python object and i don't think it makes sense to change anything. I recommend you to use a "vector", sage: vector(RDF, [1,2,3]) h On Jul 11, 6:41 pm, Carlos Cordoba wrote: >

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-11 Thread Marshall Hampton
You could also make your own sub-class like: class mylist(list): def sum(self): return sum(self) but then you would have to explicitly cast things to this class. -M. Hampton On Jul 11, 11:47 am, Harald Schilly wrote: > the int->integer replacement is done by a preparser. if you t

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-12 Thread Carlos Córdoba
Thanks for your quick answers. Coming from Mathematica, I was expecting to add lists as vectors, multiply real numbers by lists, etc, without sub-classing or using another types (such as vectors in sage) Do you advise me to add things to the preparser to have this behaviour or not? If so, how can

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-12 Thread Kevin Horton
Carlos Córdoba wrote: > Thanks for your quick answers. Coming from Mathematica, I was expecting to > add lists as vectors, multiply real numbers by lists, etc, without > sub-classing or using another types (such as vectors in sage) > > Do you advise me to add things to the preparser to have this b

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-13 Thread Harald Schilly
On Jul 12, 9:05 pm, Carlos Córdoba wrote: > Thanks for your quick answers. Coming from Mathematica, I was expecting to > add lists as vectors, multiply real numbers by lists, etc, without > sub-classing or using another types (such as vectors in sage) just to clarify this, working on lists witho

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-13 Thread Robert Bradshaw
On Jul 12, 2009, at 2:49 PM, Kevin Horton wrote: > > Carlos Córdoba wrote: >> Thanks for your quick answers. Coming from Mathematica, I was >> expecting to >> add lists as vectors, multiply real numbers by lists, etc, without >> sub-classing or using another types (such as vectors in sage) Sag

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread Paul Sargent
On 13 Jul 2009, at 17:13, Robert Bradshaw wrote: > In general, we try to avoid modifying the preparser as much as > possible. Sometimes, we really have to > > sage: eval("1/2 + 3^2") > 1 > > is really not acceptable (IMHO) for a serious alternative to other > systems out there I know what you'r

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread William Stein
On Tue, Jul 14, 2009 at 3:01 AM, Paul Sargent wrote: > > > On 13 Jul 2009, at 17:13, Robert Bradshaw wrote: > >> In general, we try to avoid modifying the preparser as much as >> possible. Sometimes, we really have to >> >> sage: eval("1/2 + 3^2") >> 1 >> >> is really not acceptable (IMHO) for a s

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread Carlos Córdoba
Sorry for not answering before, I've being a bit busy. I'll try to give a concrete example of what I'm trying to do so you can understand me better. I have a list of real numbers, for example [1,2,3] I want to multiply by 2 to get [2,4,6] the to sum it to 3 [5,7,9] then divide by the max numb

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread John H Palmieri
On Jul 14, 1:52 pm, Carlos Córdoba wrote: > Sorry for not answering before, I've being a bit busy. I'll try to give a > concrete example of what I'm trying to do so you can understand me better. > I have a list of real numbers, for example > > [1,2,3] Python "list comprehensions" might be what

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread Carlos Córdoba
Thanks John, I'd seen Python comprehensions before, but since I was trying to do all in a one-liner, I think I overlooked your elegant and simple solution. One comprehension at a time is quite neat, but several is just unreadable. On Tue, Jul 14, 2009 at 4:28 PM, John H Palmieri wrote: > > > > On

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread William Stein
2009/7/14 Carlos Córdoba : > Thanks John, I'd seen Python comprehensions before, but since I was trying > to do all in a one-liner, I think I overlooked your elegant and simple > solution. One comprehension at a time is quite neat, but several is just > unreadable. That could be a function of fam

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread John H Palmieri
On Jul 14, 3:35 pm, William Stein wrote: > 2009/7/14 Carlos Córdoba : > > > Thanks John, I'd seen Python comprehensions before, but since I was trying > > to do all in a one-liner, I think I overlooked your elegant and simple > > solution. One comprehension at a time is quite neat, but several is

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread Bill Page
> [ x ] No, I can read the above just fine. It is crystal clear. ... but of course unnecessarily verbose. In my opinion a more common notation in Sage: sage: x=2*vector(range(10))+vector(10*[3]) sage: list_plot(map(lambda a:[cos(a),sin(a)],x/max(x))) is superior to Mathematica. On Tue, Jul 14

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-14 Thread Bill Page
> [ x ] No, I can read the above just fine. It is crystal clear. ... but of course unnecessarily verbose. In my opinion a more common notation in Sage: sage: x=2*vector(range(10))+vector(10*[3]) sage: list_plot(map(lambda a:[cos(a),sin(a)],x/max(x))) is superior to Mathematica. On Tue, Jul 14

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-16 Thread Robert Bradshaw
On Jul 14, 2009, at 3:35 PM, William Stein wrote: > 2009/7/14 Carlos Córdoba : >> Thanks John, I'd seen Python comprehensions before, but since I >> was trying >> to do all in a one-liner, I think I overlooked your elegant and >> simple >> solution. One comprehension at a time is quite neat,

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-17 Thread Carlos Córdoba
> [[cos(a/9), sin(a/9)] for a in [b+3 for b in [2*c for c in [1,2,3 > > (This is using a/9 instead of a/max(z) since I don't know how to do > 'max(z)' in a one-liner like this.) > Thanks John, when I was talking about unreadable comprehensions I was meaning this. i.e. nested ones. Then was whe

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-17 Thread Laurent
Carlos Córdoba ha scritto: >> [[cos(a/9), sin(a/9)] for a in [b+3 for b in [2*c for c in [1,2,3 >> >> (This is using a/9 instead of a/max(z) since I don't know how to do >> 'max(z)' in a one-liner like this.) >> >> > > Thanks John, when I was talking about unreadable comprehensions I was

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-17 Thread Carlos Córdoba
Laurent, unfortunately that would only work for one particular program or task. I was hoping to use everywhere the kind of list operations I mentioned. Besides, the unreadability problem is still there. You have only transfered it to the function definition. On Fri, Jul 17, 2009 at 7:40 AM, Laure

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-07-30 Thread Offray Vladimir Luna Cárdenas
Hi, Bill Page escribió: >> [ x ] No, I can read the above just fine. It is crystal clear. >> > > ... but of course unnecessarily verbose. In my opinion a more common > notation in Sage: > > sage: x=2*vector(range(10))+vector(10*[3]) > sage: list_plot(map(lambda a:[cos(a),sin(a)],x/max(x)))

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-08-02 Thread Robert Dodier
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. No

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-08-02 Thread William Stein
On Sun, Aug 2, 2009 at 9:13 AM, Robert Dodier 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- >> i

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-08-02 Thread Carlos Córdoba
On Sun, Aug 2, 2009 at 2:00 PM, William Stein wrote: > > On Sun, Aug 2, 2009 at 9:13 AM, Robert Dodier > 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'

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-08-03 Thread Pierre
> 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. IMHO, an expression like 1 + [2,3,4,5] i

[sage-support] Re: Is it possible to replace the list built-in type in Sage?

2009-08-03 Thread Jason Grout
William Stein wrote: > On Sun, Aug 2, 2009 at 9:13 AM, Robert Dodier 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