On Thu, Oct 20, 2011 at 3:02 PM, Viktor Cerovski <[email protected]> wrote: > Henry points out that any number can be interpreted as an > array with an empty shape. Then, there is also an interpretation > that an array with an empty shape can be considered a scalar. > So, in this above case this scalar is 123, so why not call, interpret, > think of it as of a number?
Sure, and the distinction between 123 and i.3 4 is that the later case involves multiple numbers and is not "a number". But, by this reasoning, a one element list would also be "a number", and so would a 1 by 1 matrix. (Assuming, of course, that the value contained is numeric.) In other words, the distinction between "a number" and "some numbers" probably does not depend on how many dimensions we are working with but probably instead depends on how many values are present. Then again, leading "1" dimensions never change the number of values we are working with. > e=:0$0 NB. empty array ... > So far so good. But how do we then explain the following: > > }.123 "Drop the first element from the list 123". Well, 123 is not actually a list, but it's trivial to treat it as a list containing one element so let's drop the first element from that list instead. This is probably mostly a convenience for people performing manual experiments. > e -: }.123 > 1 Dropping the first element from a one element list gives us an empty list. > 123 -: 123,e > 0 123 was not actually a list so its not identical to appending an empty list with 123. > (In English: appending/prepending an empty array to > an array does not change it.) This is not always the case, though it is the case when all arrays have exactly one dimension. For example, here I append two empty arrays and get a non-empty result: (i.0 1 2),i.2 1 0 > So from this follows the conclusion that 123 is not an array, > while 1$123 is. My conclusion is that 123 is not a 1 dimensional array. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
