home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / language / j32.sit / j.rsrc / TEXT_201_Nouns.txt < prev    next >
Text File  |  1991-06-13  |  3KB  |  85 lines

  1. NOUNS
  2.  
  3. Nouns are classified in three independent ways: numeric or literal; open or boxed; arrays of various ranks. In particular, arrays of ranks 0, 1, and 2 are┬ácalled atom, list, and table, or, in mathematics, scalar, vector, and matrix. Numbers and literals are represented as stated in  ALPHABET & WORDS (q.v.).
  4.  
  5. Arrays.  A single entity such as 2.3 or _2.3j5 or 'A' or '+' is called an atom. The verb denoted by comma chains its arguments to form a list whose shape (given by the verb $) is equal to the number of atoms combined. For example:
  6.  
  7.       date=. 1,7,7,6
  8.       $ date
  9. 4
  10.    |. date
  11. 6 7 7 1
  12.       word=. 's','a','w'
  13.       |. word
  14. was
  15.  
  16. The verb |. used above is called reverse. The phrase s$b produces an array of shape s  from the list b. For example:
  17.  
  18.       (3,4) $ date,1,8,6,7,1,9,1,7
  19. 1 7 7 6
  20. 1 8 6 7
  21. 1 9 1 7
  22.       table=. 2 3$ word,'bat'
  23.       $ table
  24. 2 3
  25.    table      
  26. saw
  27. bat
  28.  
  29. The number of atoms in the shape of a noun is called its rank. Each position of the shape is called an axis of the array, and axes are referred to by indices 0, 1, 2, etc. For example, axis 0 of table has length 2 and axis 1 has length 3. The last k axes of an array b determine rank-k cells or k-cells of b. For example, if:
  30.  
  31.    b=.2 3 4 $'abcdefghijklmnopqrstuvwx'
  32.       b
  33. abcd
  34. efgh
  35. ijkl
  36. mnop
  37. qrst
  38. uvwx
  39.  
  40. then the list abcd is a 1-cell of b, and the letters are each 0-cells of b.
  41.  
  42. The rest of the shape vector is called the frame of b relative to the cells of rank k. Thus, if $c is 2 3 4 5, then c has the frame 2 3 relative to cells of rank 2, the frame 2 3 4 5 relative to 0-cells (atoms), and an empty frame relative to 4-cells.
  43.  
  44. A cell of rank one less than the rank of b is called an item of b, and items play an important role in the discussion of nouns and the application of verbs to them. For example, the verb from (denoted by {) selects items from its right argument, as in: 
  45.  
  46.       0{b             1{b             0{0{b
  47. abcd            mnop            abcd
  48. efgh            qrst
  49. ijkl            uvwx
  50.  
  51.       2 1{0{b            1{2{0{b
  52. ijkl                      j
  53. efgh
  54.  
  55. Moreover,  the verb grade (denoted by /:) provides indices to { that bring items to "lexical" order. Thus:
  56.  
  57.       g=./:n=.4 3$3 1 4 2 7 9 3 2 0
  58.       n               g                g{n
  59. 3 1 4           1 0 3 2           2 7 9
  60. 2 7 9                                   3 1 4
  61. 3 2 0                                   3 1 4
  62. 3 1 4                                   3 2 0
  63.  
  64. Negative numbers, as in _2-cell and _1-cell (an item), are also used to refer to cells whose frames are of the length indicated by the magnitude of the number. For example, the list abcd may be referred to either as a _2-cell or as a 1-cell of b.
  65.  
  66. Open and Boxed.  The nouns discussed thus far are called open, to distinguish them from boxed nouns produced by the verb box denoted by <. The result of box is an atom, and boxed nouns are displayed in boxes. Box allows one to treat any array (such as the list of letters that represent a word) as a single entity, or atom. Thus:
  67.   
  68.    letters=. 'I was it'
  69.    $letters
  70. 8
  71.    |. letters
  72. ti saw I
  73.    words=.(<'I'),(<'was'),(<'it')
  74.    $words
  75. 3
  76.    |. words
  77. +--+---+-+
  78. |it|was|I|
  79. +--+---+-+
  80.    2 3$words,|.words
  81. +--+---+--+
  82. |I |was|it|
  83. +--+---+--+
  84. |it|was|I |
  85. +--+---+--+