On 9/21/07, John Cremona <[EMAIL PROTECTED]> wrote: > For what it's worth, I too am against using either form of "open-ended > interval" notation such as [a,b), [a,b[ and so on. Let's keep > brackets matching; both those notations are used in Mathematics (the > latter mainly in the French world), but *only* for intervals of reals > where it is necessary. I cannot see why anyone would want to write > (0..10) to mean the same as [1..9], i.e. [1,2,3,4,5,6,7,8,9].
It also doesn't make any sense in the context of Python. Square brackets should be for making list and round brackets for iterators -- that's just how Python works. > But the use of .. for *inclusive* ranges does seem very natural to me, > despite not being in Pyuthon proper, and I would agree with Peter > Doyle's remarks on that for undergraduate teaching. It's in. Upgrade to sage-2.5 and try it out right now. sage: [1..10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] sage: [1,3..20] [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] sage: [5..15] [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] sage: [5..15,30..40] sage: time matrix(ZZ,500,[1..500^2]).rank() CPU times: user 0.39 s, sys: 0.02 s, total: 0.41 s sage: m = ModularSymbols(37) sage: [m.T(n).charpoly() for n in [1..6]] [x^5 - 5*x^4 + 10*x^3 - 10*x^2 + 5*x - 1, x^5 + x^4 - 8*x^3 - 12*x^2, ...] > [Aside: Peter, does Dartmouth still teach BASIC to all undergratuates > (in all majors) like they did when I was there 1982-84? That was when > Kemeny was still revered by all, and part of te requirement was that > every single undergrad had to watch the 2-part video of Kemeny > explaining BASIC programming.] > > John > > On 9/20/07, William Stein <[EMAIL PROTECTED]> wrote: > > > > ---------- Forwarded message ---------- > > From: Peter Doyle <[EMAIL PROTECTED]> > > Date: Sep 20, 2007 9:04 AM > > Subject: Re: [sage-devel] Regarding range and '..' operator > > To: William Stein <[EMAIL PROTECTED]> > > > > > > Hi William, > > > > I am glad you have not abandoned your suggestion of introducing the > > 1..10 notation, which I think is absolutely brilliant. I am new to > > Python, and while I am not 100% keen on it, I do appreciate the clean, > > simple syntax. From long experience using computers in undergrad > > courses, I understand that there are great benefits to being able to > > tell at a glance what a (simple) program is supposed to do. Unless > > programming is the subject of the course, there is no time to spare > > for semicolons and underscores. if I want students to be able to > > modify existing programs, and write simple programs of their own, the > > language has to be simple, in a way that Python mostly is. If I'm > > going to use SAGE in a probability course, it will be a huge advantage > > to have this simple, crystal clear syntax for loops, conditionals, > > function definitions. Students are going to know at a glance how > > simple demo programs work. Except for the problem with range(). But > > if I can write > > > > for i in 1..10 > > > > instead of > > > > for i in xrange(1,11) > > > > then we'll be golden. Well, until we crash into other peculiarities > > of Python, like the way I can accidentally redefine the default value > > of a list argument, or otherwise accidentally modifiy an argument > > passed by reference. But that's way down the road, and we'll likely > > not run into that in a probability course or a calculus course. > > > > Cheers, > > > > Peter > > > > Cheers, > > > > Peter > > > > > > -- > > William Stein > > Associate Professor of Mathematics > > University of Washington > > http://wstein.org > > > > > > > > > > -- > John Cremona > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---
