Roger,
When migrating from APL to J there were bigger issues (as in learning new
tricks) than index origin. (Like concept of working on items especially with
reshape).
I believe that index origin 0 is the "appropriate" choice even though I
sometimes get caught up when counting positions in array and then using that
constant in J expressions. The brain knows about it but mistakes can happen
especially when dealing with inner dimensions. (leading and trailing dimensions
I seem to usually get correct - dare I say first and last). The good practice
is to set up and use pronouns as indexes, but while it is possible to "strand"
scalar numeric constants (as in 3 1 5 { array) pronouns require a verb to
combine them ((iSpecies, iID, iSex) { array)
"Appropriate" choice as shown by the following where the index is a calculation
from data unrelated to the array being indexed.
(list +./@:(*./ . =) data) { 'missing';'found'
((<data) e. <"1 list) { 'missing';'found'
(16 16 16 16 #: 4011 61453) { '0123456789ABCDEF'
( 3 <. +/ someArray = value) { 'none';'one';'two';'many'
"base" and "plus insert" are two verbs that I like to use for index
calculations.
On one major APL project ([]IO <- 1) I worked on as part of a maintenance team
I consistently recoded expressions like those above as ARRAY [ []IO +
calculation ;] to make plain that the 1 was there only because the calculation
yields a result suitable for index origin 0.
===========================
Summary: 0 is the right choice - it make the calculation of indexes cleaner -
if there is a constant added then it is there because of other necessities
related to the problem. However, because of long time "learning" it is
possible to slip up.
Background: mathematics, statistics, computer science.
Current position: statistician
Ian Shannon
Landscape Modelling and Decision Support Section
Department of Environment, Climate Change & Water (NSW)
PO Box A290 Sydney South
NSW 1232
Phone: (02) 99 955 490
Mob: 0428 296 729
email: [email protected]
web: http://www.environment.nsw.gov.au
Please consider the environment before printing my email
On Sat, Jul 24, 2010 at 3:16 PM, Roger Hui <[email protected]> wrote:
> does the choice of a fixed value of 0 for index origin a
> hindrance to your work?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential
and/or privileged information.
If you are not the intended recipient, please notify the sender and then delete
it immediately.
Any views expressed in this email are those of the individual sender except
where the sender expressly and with authority states them to be the views of
the Department of Environment, Climate Change & Water NSW.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm