I'm very happy thinking of a scalar as a zero rank array. I.e. scalars
aren't distinct from arrays, they are just a type of array.

Distinguishing a scalar from a single-element list can be confusing,
but the same issue applies to lists and single-row tables etc. It is
not confined to scalars vs arrays.

On Fri, Oct 21, 2011 at 5:28 PM, Alan Stebbens <[email protected]> wrote:
> On Oct 20, 2011, at 8:24 PM, Roger Hui wrote:
>
>> You have to use a different word than "noun".  It's already taken and
>> it means "array".
>
> Roger,
>
> I have to agree with Rich.
>
> With all due respect (and that is not a trite phrase -- I really _do_ respect 
> the tremendous work and thought that you have put into APL and J), it seems 
> incorrect to me to say that the word "noun" means "array".
>
> The object on which verbs operate, that is, a noun, can be either an array, 
> or a scalar.
>
> The J Primer says that
>
>> In the following sentence the numbers 2 and 5 are both nouns.
>>
>>    2 + 5
>
> In the example, both 2 and 5 are scalars.   So, a noun, by definition, is at 
> least a scalar.
>
> But, from other examples, we know that a noun can also be an array.
>
> So a noun is either a scalar or an array.
>
> This can be demonstrated in J itself:
>
>>    f =: 3 : 0
>> (('Rank';$$y),:('Shape';$y)),'Tally';#y
>> )
>>    f ''   NB. strings are arrays, even empty strings
>> ┌─────┬─┐
>> │Rank │1│
>> ├─────┼─┤
>> │Shape│0│
>> ├─────┼─┤
>> │Tally│0│
>> └─────┴─┘
>>    f 1     NB. pass a scalar (no rank)
>> ┌─────┬─┐
>> │Rank │0│
>> ├─────┼─┤
>> │Shape│ │
>> ├─────┼─┤
>> │Tally│1│
>> └─────┴─┘
>>    f ,1    NB. pass an array of one scalar
>> ┌─────┬─┐
>> │Rank │1│
>> ├─────┼─┤
>> │Shape│1│
>> ├─────┼─┤
>> │Tally│1│
>> └─────┴─┘
>>    f 1 2   NB. pass an array of two scalars
>> ┌─────┬─┐
>> │Rank │1│
>> ├─────┼─┤
>> │Shape│2│
>> ├─────┼─┤
>> │Tally│2│
>> └─────┴─┘
>>    f 0$1   NB. pass an empty array (zero shape)
>> ┌─────┬─┐
>> │Rank │1│
>> ├─────┼─┤
>> │Shape│0│
>> ├─────┼─┤
>> │Tally│0│
>> └─────┴─┘
>>    f ''$1  NB. pass a null rank object (scalar)
>> ┌─────┬─┐
>> │Rank │0│
>> ├─────┼─┤
>> │Shape│ │
>> ├─────┼─┤
>> │Tally│1│
>> └─────┴─┘
>
> Alan
>
>
> ----------------------------------------------------------------------
> 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