I'm not completely sure what you are getting at here, actually.

When I was learning APL, I was taught that a scalar was a rank zero
array. And it seems to me that J uses the same design.

If you look at J's 3!:1 and 3!:2 foreigns (or you can use 3!:3 instead
of 3!:1 if you prefer), you'll see that J uses the same data structure
for arrays regardless of rank (There's size differences, of course, in
the dimension and the data). If you are working in a strongly typed
environment, you'll probably want to be using a dependent type system.

That said, APL2 did pull some shenanigans with rank zero arrays and
infinity. J follows the Sharp APL design instead of the APL2 design,
if that is what you were asking about.

I hope this helps,

-- 
Raul


On Tue, Dec 19, 2017 at 4:28 AM, Erling Hellenäs
<[email protected]> wrote:
> Hi all !
>
> In APL we had the same array model as in Fortran. An array was an array and
> you indexed it like in most other languages, except that you could use an
> array as index and therefore could get very varying results. The only
> problems I personally experienced with this model was that you could not put
> all the indexes in one variable. I also wanted to have the index to the
> left. To keep the right-to-left normal flow of the language. I wrote special
> indexing functions to handle this, but never used them in production.
>
> In J we have the n-cell array model. A difference is that a scalar is just
> another array, it just is imagined as having zero dimensions. I APL there
> were scalars and there were arrays, basically two different data structures.
> I experience an inconsistency in this model in the sense that an array of
> rank greater than zero can be empty, a 0-cell can not. At least in the
> interpreter I wrote, there is a lot of special handling of 0-cells because
> they actually have content, although there are no array dimensions which
> could reasonably contain any such content.
>
> In the dyadic rank operator a k-cell without any zero dimension can be empty
> because a containing array is. This causes the very particular special
> handling I mentioned in the thread "[Jprogramming] i. (2 2 $ 1 2 3 4)"
>
> Simplicity is important for performance, it is important for our ability to
> predict the behaviour of the code without testing it in the terminal and to
> limit the number of test cases needed to verify the functonality of a
> program.
>
> Is there any documentation of the design decision to select the n-cell array
> model?
>
> Are there any threads in the forum where this array model is discussed?
>
> Maybe someone also wants to share their knowledge from internal discussions
> about this design decision.
>
> Cheers,
>
> Erling Hellenäs
>
> ----------------------------------------------------------------------
> 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