
On Tue, 28 Aug 2001, Eric Nodwell wrote:
Does anyone have a simple method of using one-offset arrays? Specifically, can I define an array "a" so that a[1] refers to the first element?
Inherit from the UserArray and redefine slicing to your hearts content.
Without one-offset indexing, it seems to me that Python is minimally useful for numerical computations. Many, perhaps the majority, of numerical algorithms are one-indexed. Matlab for example is one-based for this reason. In fact it seems strange to me that a "high-level" language like Python should use zero-offset lists.
Wow, that is a pretty condescending-sounding statement, though I'm sure you didn't mean it that way. Python is indeed being used for quite serious numerical computations. I have been using Python for quite some time for Numerical work and find it's zero-based indexing combined with the leave-last-one-out slicing notation to be much more convenient.
It is different from MATLAB but that hardly makes it less useful as I suspect you'd agree after trying it out for awhile.
What is your application domain that so requires 1-based indexing.
Travis E. Oliphant, Ph.D. Assistant Professor Brigham Young University Provo, UT 84602 (801) 378-3108 oliphant.travis@ieee.org