Sequences and Factorials


                #=
                This code shows how to generate a matrix using a mixture of static values and computed values. 
                The length of a sequence is in the top left corner.
                The sequence is the first row.
                It is converted to a row vector using the adjoint operator.
                A factorial, the same length as the sequence, goes down the left side.
                It is in reverse order, counting down to 2.
                The computation 'col mod row' goes in the remaining rows and columns.
                The array is constructed using a newline to create rows and tabs to create columns.
                =#
                seq = 12:19
                len = length(seq)
                factors = len:-1:2

                [len     seq'
                factors [( mod(col,row) ) for row in factors, col in seq]]
            

Coding Lesson

Constructing a matrix

Note:

  1. The use of a space to horizontally separate len from seq'
  2. The newline to begin a new row and then, multiple rows added using:
  3. The vector factors then a space for horizontal travel (again) and the computed rest of the matrix.
  4. The use of the adjoint operator on seq to convert it to a row vector.
  5. The multi-line comments.