 ==================================================================
      LESSON 5: Rank and the 'Over' and 'Integer' Verbs ( " / i. )
 ==================================================================

      In J, the verb 'i.' will produce a set of integers:

      i. 9
 0 1 2 3 4 5 6 7 8

      a=. i.5
      a
 0 1 2 3 4

      The integer verb can also be given a shape:

      i. 2 3
 0 1 2
 3 4 5

      i. 3 7
  0  1  2  3  4  5  6
  7  8  9 10 11 12 13
 14 15 16 17 18 19 20

      This is a handy way of generating tables for practice.

      a=. i. 3 7
      $a
 3 7

      J considers dimensions as 'ranks'.  A single atom, such the number
      '3' for example, has rank 0.  A vector or list of numbers has rank
      1.  A matrix or table has rank 2.  The rank verb is the double
      quote '"'.   Therefore, "1 denotes rank 1.

       Let's return to the problem where the tally verb ('#') did not
      produce the results we wanted...

      #a
 3
      a
  0  1  2  3  4  5  6
  7  8  9 10 11 12 13
 14 15 16 17 18 19 20

      Now we try using the rank verb.

      #"2 a
 3
      #"1 a
 7 7 7
      #"0 a
 1 1 1 1 1 1 1
 1 1 1 1 1 1 1
 1 1 1 1 1 1 1

      Do you see how the different ranks were tallied?

      #"3 a
 3
      Still, we have not managed to come up with a total number of atoms
      for our table.  Do we need another verb?

 ==================================================================
      OVER   ( / )
 ==================================================================

      'Over', symbolized by the forward slash ('/'), distributes a
      verb operation over all the atoms in a pronoun.  For example,
      '+/' will sum all of the values.  '*/' will multiply all of
      the values.  'Over' is not really a verb at all, it is an ADVERB:
      it works with verbs in the same way English adverbs work with
      verbs.  Here are some examples:

      b=. 3 6 8 2
      b
 3 6 8 2
      +/b
 19
      3+6+8+2
 19
      */b
 288
      3*6*8*2
 288

      a
  0  1  2  3  4  5  6
  7  8  9 10 11 12 13
 14 15 16 17 18 19 20
      +/a
 21 24 27 30 33 36 39
      */a
 0 120 288 510 792 1140 1560

      Notice that in a table, the verb acted on each column.  If we want
      it to act on another rank of the table, we must use the rank
      verb:

      +/"1 a
 21 70 119
      0+1+2+3+4+5+6
 21
      7+8+9+10+11+12+13
 70

      You see that the rank 1 expression gave us the totals by row, rather
      by column.

      Now, to get a total number of atoms, we need to combine the tally
      verb with over and rank:

      +/#"1 a
 21
      Try variations of this exercise until you've become used to it.

 ==================================================================
      END OF LESSON 5
 ==================================================================

