Hi Nasser, 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 don't think what you're describing is odd at all. The command "range" in sage: [f(i) for i in range(1, 11)] is, I think, actually a built-in function of Python and Sage merely uses that function. In the above code, Sage is calling the "range" function of Python, which is defined that way. For example, for integer n > 0, the command range(n) returns 0, 1, 2, ..., n-1 which is how range is defined as a built-in function. A similar comment applies to range(j,k), in which case the command stops after going past k-1. The above comments also apply to xrange, which in some cases is much more efficient. From within a Sage session at the console, you can use any of the following commands sage: help(range) sage: help(xrange) to find out more about range and xrange. -- Regards Minh Van Nguyen Web: http://nguyenminh2.googlepages.com Blog: http://mvngu.wordpress.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---