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

Reply via email to