I recently attempted to describe some features of J to a group of expert R
programmers. In the process it seemed essential to emphasize two things.
(1) In J every noun is an array
(2) The concept of rank provides an extraordinary, powerful, consistent
mechanism for controlling all interactions between functions and data.
When every data object is an array the number of axes or the conventional
concept of dimension of the array specifies an important attribute of the
data. Oleg suggested we should give more emphasis to both the terms, axes
and dimension. I agree.
The atoms - numbers, characters, boxes have attributes of their own. In J
it is their type.
An atom is a noun of dimension 0. It has empty shape.
A vector is defined in the DoJ as a list of atoms. It has dimension 1. Its
items have an empty shape.
Its shape is a single element vector, which is simply the number of items
(tally) in the list.
A dimension n noun is simply a list of dimension n-1 nouns of the same
shape. Each time we form a list, we add to the set of axes over which the
array is defined. Each atom in the array becomes a value at some point in a
discrete n dimensional space.
I think Oleg suggests referring to the location in the shape vector as the
axis. For most high dimensional nouns it is essential to be able to refer
to specific axes. Using axis for that is consistent with common usage in
many contexts.
In the recursive style above the shape of an array is the number of items in
the list catenated with shape of the items.
Using dimension, axis and shape in this way enables a clear specification of
different attributes of an array. It is different from the DoJ which uses
the term rank for what I have called dimension. That causes some confusion
for reasons outlined below.
Second, the rank conjunction (and I believe the rank concept) should be
regarded as the means of specifying exactly how any verb(function) is
applied to the array(s) in its argument(s). It provides a clear tool for
identifying how elements from an array are used in function execution, and
for determining the shape of the result of the function.
In the DoJ rank is used three ways. It is used for the conjunction, it is
used to specify the dimension in the sense above (II.A) and it is used to
specify the dimension of a function argument or arguments(II.B). I have the
greatest respect for the years of careful work which Ken and Roger have put
into the DoJ but I think the word rank is used for too many related but
distinct ideas.
The rank conjunction specifies the cells to which a verb is applied. In DoJ
II.B the rank of a verb specifies the dimension of cells to which it is
applied with "The ranks of a verb merely place upper limits on the ranks of
the cells to which it applies; its domain may include arguments of lower
rank." Extension to higher dimension arrays is automatic. If the verb is
of rank k and the dimension of the array is n then the shape of the frame
is a prefix of the shape vector of the result.
The frame and the cell create a partition of the axes of the array. The
dimension of the frame is the number of axes not in the cell. By permitting
both positive and negative numbers in the rank specification the method of
selecting elements from the arrays is enriched and avoids prior
specification of the dimension of an array.
The rank _ means the frame has an empty shape.
Rank _1 means it has shape the first element of the shape of the array
Rank _2 means it has the shape of the first two elements of the shape array.
There are clear conventions when (-the frame dimension) exceeds the array
dimension.
In general, the result shape is shape (shape of frame), (shape of result
applied to the cell shape).
For the application of any verb the ranks specify how elements will be
selected from the arguments. The elements selected are arrays of specific
dimensions. Keeping the dimension, axes and shape of the arguments with
their own specific terms is important if we want to simplify the discussion
of the way in which verbs interact with them. For that the concepts of
rank, frame and cell are central.
In the context of a J sentence both the rank of the verb and the dimensions
of the data arrays are important. The dimensions of the result will depend
on the verbs, the rank specification and the dimensions of the data arrays.
Restricting rank to refer to ways in which elements are selected and
processed by our verbs helps clarify detailed specification of the
algorithms we want executed. Of course one of the great features of J is
that for many verbs the default specification of the ranks is exactly what
we want.
Fraser
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm