J data values Feb 1994. ------------------------- Scalar, Atom ------------ eg. 7 an integer _3 a negative number _ infinity __ negative infinity _. undefined number 3.14 a real number 1j2 a complex number 's' a character a boxed item eg. < i. 2 3 --> +-----+ |0 1 2| |3 4 5| +-----+ Vector or list -------------- eg. 1 2 3 i. 7 --> 0 1 2 3 4 5 6 3 * 2 4 8 --> 6 12 24 'string' --> string Array or table -------------- i. 2 3 --> 0 1 2 3 4 5 1 2 4 */ 1 2 3 4 --> 1 2 3 4 2 4 6 8 4 8 12 16 Higher Dimensional Arrays ------------------------- eg. i. 2 3 4 --> 0 1 2 3 the 0-axis has length 2 4 5 6 7 the 1-axis has length 3 8 9 10 11 the 2-axis has length 4 12 13 14 15 ) 16 17 18 19 ) <-- a rank-2 cell of i. 2 3 4 20 21 22 23 ) 0 1 2 3 is a rank-1 cell and 7 is a rank-0 cell Boxed Items < -------------- Boxing turns a structured item into an atom and can be used to make arbitrary structures. eg. a =. < 'leafA' b =. < 'leafB' c =. < 'leafC' d =. ( +-----------------------+-----+-------+ E |--------+-----+-------+|forkE|+-----+| . . ||+-----+|forkD|+-----+|| ||leafC|| . . |||leafA|| ||leafB||| |+-----+| D C ||+-----+| |+-----+|| | | . . |+-------+-----+-------+| | | . . +-----------------------+-----+-------+ A B $t --> 3 (t is 3 boxes, see shape $ below) $ > 0{t --> 3 (left(t) is a subtree) $ > 1{t --> 5 (elt(t) is 'forkE') $ > 2{t --> empty list (right(t) is a leaf, a boxed string) Shape $ (dimensions) -------------------------- $ 7 --> the empty list $ $ 7 --> 0 $ $ $ 7 --> 1 $ $ $ $ 7 --> 1 etc. $ i. 7 --> 7 $ $ i. 7 --> 1 $ $ $ i. 7 --> 1 etc $ i. 2 3 4 --> 2 3 4 $ $ i. 2 3 4 --> 3 $ $ $ i. 2 3 4 --> 1 etc. $ 's' --> the empty list $ ,'s' --> 1 $ 'string' --> 6 $ < i. 2 3 --> the empty list Tally # (number of items) ------------------------------- # 7 --> 1 # i. 3 --> 3 # i. 2 3 --> 2 # i. 2 3 4 --> 2 #"1 i. 2 3 --> 3 3 (see rank of a verb) # 'string' --> 6 # < i. 2 3 --> 1 Rank #$ (dimension) ------------------------- #$ 7 --> 0 #$ i. 3 --> 1 #$ i. 2 3 --> 2 #$ i. 2 3 4 --> 3 #$ 'string' --> 1 $# < i. 2 3 --> 0 i. 2 3 4 --> 0 1 2 3 has rank 3 4 5 6 7 7 is a rank-0 cell 8 9 10 11 8 9 10 11 is a rank-1 cell etc 12 13 14 15 ) 16 17 18 19 ) <--------- a rank 2 cell 20 21 22 23 ) Rank of a verb: --------------- A verb of rank k applies to each of the rank-k cells of its argument. The conjunction " can change the rank of a verb eg. #"1 i. 2 3 --> 3 3