How about this: the shape of the disclose of an array of arrays is the
concatenation of the "outer" and "inner" shapes, e.g.:
$> 1 2$<3 4$99
1 2 3 4
$> 2$<3 4$99
2 3 4
$> 1$<3 4$99
1 3 4
$> (i.0)$<3 4$99
3 4
$> ''$<3 4$99
3 4
$> <3 4$99
3 4
That is, you need a way to have an empty shape to avoid inadvertently
increasing
the rank of an array upon disclosing it (if you wish to be consistent).
Note that other languages, I'm looking at you Matlab, are happily
inconsistent and
are also happy with less-than-general array-handling. In Matlab, a "vector"
is a matrix
with a 1 in one of its dimensions, so a 1x3 and a 3x1 are both "vectors";
also, a "scalar"
has 1 as both its dimensions; hence, in Matlab, a "scalar" is a "vector".
See
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/index.html?/access/helpdesk/help/techdoc/ref/isvector.html
and
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/index.html?/access/helpdesk/help/techdoc/ref/isvector.html
.
On 10/24/06, Pascal Jasmin <[EMAIL PROTECTED]> wrote:
it still feels like a stretch, but your point of growing a data structure
is fair.
These seem hard to understand though.
(i.0) $2
2
'' $ 2 3
2
----- Original Message ----
From: Devon McCormick <[EMAIL PROTECTED]>
To: Programming forum <[email protected]>
Sent: Tuesday, October 24, 2006 8:38:45 PM
Subject: Re: [Jprogramming] Words cell format -- shape of an atom
It's a paradox only if you consider consistency to be paradoxical - which
it
is for most programming languages.
Consider that a 2-dimensional array can be extended along 2 axes:
a2=. 1 1$1
a2;(a2,1);a2,.1
+-+-+---+
|1|1|1 1|
| |1| |
+-+-+---+
Analogously, a 1-dimensional array can be extended only along 1 axis:
a1=. 1$1
a1;(a1,1);a1,.1
+-+---+---+
|1|1 1|1 1|
+-+---+---+
Finally, a 0-dimensional array cannot be extended along any axis
because it does not have any axes. When it is concatenated with
something, it is no longer a scalar (0-dimensional array).
Another way of putting this is that the result of $ is always a vector:
for a 2-dimensional array, it is a vector of length 2; for a 1-dimensional
array it is a vector of length 1; and for a 0-dimensional array it is a
vector of length 0.
The usefulness of this consistency can be seen by understanding
that we can predict the shape of 2 arrays compared orthogonally (all
elements to all elements) by simply adding the shapes of the 2 arrays:
$(2 3 4$1) =/ 5 6$1
2 3 4 5 6
#$((5$1)$1) =/ (2$1)$1 NB. 5+2 = 7
7
#$((5$1)$1) =/ (1$1)$1 NB. 5+1 = 6
6
#$((5$1)$1) =/ (0$1)$1 NB. 5+0 = 5
5
1-:(0$1)$1
1
On 10/24/06, Miller, Raul D <[EMAIL PROTECTED]> wrote:
>
> Pascal Jasmin wrote:
> > why the shape of an atom isn't 1 is the paradox :)
>
> --
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm