[Jprogramming] index origin 0
Alex Rufon
alex_rufon at ist-systems.com
Tue Jul 27 07:48:08 HKT 2010
I have a degree in economics and have been working as a software developer for 18 years. My current job title is Technical Consultant II but I primarily do back-end and data intensive computations where I use J. All of the people I work with have a degree in computer programming (I was the odd one in the pack coming from a business course) so it's really nice to know that a lot of J users have a background in economics and some are dyslectic like me ... I do hope that I'm the only one who's really bad in arithmetic though.
On the 2nd quarter of 2004, our company had a standardization review for the whole technical team. Although it covered a lot of things, which eventually led us to the development of our in-house RAD tool, one of the most argued topic was the use of 0 or 1 as the index origin. A lot of research was put on the table but in the end, 1 was the index origin. The outcome of this discussion led to the creation of libraries in the programming language that we use and our standard J libraries contains code snippets such as this:
from
+-+-+-------------------------------------+
|4|:|NB. indices-of-elements (IO=1) from y|
| | |(_1 + x) { y |
+-+-+-------------------------------------+
int
+-+-+----------------------------------+
|3|:|NB. integers from 1 to y with IO=1|
| | |1+ i. y |
+-+-+----------------------------------+
Column selection looks like this:
NB. Create the test data, notice the numbers start with 1
[test=. int 3 5
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
NB. Retried the 2nd column
2 colsfrom test
2 7 12
NB. Retrieve the 2nd and 1st rows
2 1 rowsfrom test
6 7 8 9 10
1 2 3 4 5
Since I qualify, my answer is that a fixed value of 0 is not a hindrance to my work. J is versatile enough that we can create libraries where we can choose the index origin.
-----Original Message-----
From: programming-bounces at jsoftware.com [mailto:programming-bounces at jsoftware.com] On Behalf Of Roger Hui
Sent: Saturday, July 24, 2010 9:17 PM
To: Programming forum
Subject: [Jprogramming] index origin 0
I have been asked by some APL colleagues about index origin 0 in J. The question is, does the choice of a fixed value of 0 for index origin a hindrance to your work? The question is specifically addressed to "ordinary domain experts", people with no software engineering in their background and are not professional mathematicians.
In case you did not know, in APL there is a choice known as the index origin, controlled by the variable quad-io, of counting from 1 instead of from 0, affecting the left argument of { and the result of i. , among other things.
I will say no more than this to avoid biasing your answers.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list