On Nov 10, 2008, at 11:23 AM, Nasser Abbasi wrote: > Hello; > > I was just browsing something to learn about sage, and noticed this on > this web site > http://wiki.sagemath.org/sage_mathematica > > where it says: > > "sage: [f(i) for i in range(1, 11)] > [g(1), g(2), g(3), g(4), g(5), g(6), g(7), g(8), g(9), g(10)] > > (note that the endpoint of the range is not included). " > > The above struck me as something that would be confusing and will lead > to many programming errors. I do not program in Python and played > with sage very little. But it seems (to me) strange that when one > write range(i,j) that the sequence will stop at j-1. > > Do other who worked with sage more not find this is a bit odd?
I would say it's a question of whether or not one is used to working with a (mainstream) programming language like C, java, python, php, javascript, ... This goes back to the fact that arrays are 0-indexed, i.e. sage: L = [1,4,8] sage: L = ['a', 'b', 'c'] sage: L[0] 'a' sage: L[1] 'b' You might prefer the [1..n] notation, so you could do sage: [f(i) for i in [1..10]] [g(1), g(2), g(3), g(4), g(5), g(6), g(7), g(8), g(9), g(10)] (This really should be added to the wiki.) - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---