## , Catenate, Laminate

Two-argument form See also one-argument form Ravel

### Catenate

Catenate joins data items together.

With single-element items and vectors, catenate works very simply.

                 10,66                   (2 numbers are joined to form
           10 66                          a 2-element vector)

                 '10 ','MAY ','1985'     (3 vectors of characters are joined
           10 MAY 1985                    to form an 11-element vector)

With matrices and other multi-dimensional arrays, catenate expects the dimension at which the join is made to be specified. (See [], 'axis'.) If no dimension is specified, the last dimension is assumed. ® (comma-bar) behaves in exactly the same manner as , except that the default dimension is the first. Again, if an axis is specified ® will use that axis.

The dimension at which items are joined must be the same length. Thus if two matrices are joined 'at' the columns dimension, the columns must be the same length. If a scalar is joined to a matrix, it's repeated along the dimension at which the join takes place. The examples below assume ŒIO is 1, the default.

Given the following three matrices called A, B, and D

                 A                   B                   D
           1  2  3  4           5  6               13 14 15 16 17 18
           7  8  9 10          11 12               19 20 21 22 23 24
                 C „ A,B                 (A and B are joined to form C,
                 C                        Since no dimension is specified,
           1  2  3  4  5  6               the join is at the last dimension
           7  8  9 10 11 12               ie the columns.   Note that A and
                                          B have the same number of rows.)

                 C,[1]D                  (C and D are joined at the
            1  2  3  4  5  6              first dimension, ie at the rows.
            7  8  9 10 11 12              Note that C and D have the same
           13 14 15 16 17 18              number of columns.)
           19 20 21 22 23 24

                 A,[1]0                  (A single number is joined to A.
           1  2  3  4                     The join is at the row dimension.
           7  8  9 10                     The number is repeated along that
           0  0  0  0                     dimension.)

### Laminate

Catenate can only produce a result of the same dimension but of enlarged shape - a two-dimensional structure becomes a larger two-dimensional structure. Laminate joins two objects of identical shape and dimension to form a higher dimensional object.

                 'ABC',[0.5]'DEF'        (Two 3-element vectors are joined
           ABC                            to form a 2-row, 3-column matrix.
           DEF                            Note the figure in square brackets
                                          and the fact that it is less than 1)

Laminate creates a new object which has the same shape as the constituent parts except for the addition of a new dimension.

So in the example above the original vectors are size 3. Their lamination produces a matrix of size 2 3. The dimension added by laminate is of size 2. This dimension is placed in respect to the old dimension according to the number in brackets. With ŒIO set to 1, the default, if this number is less than 1, the size 2 dimension goes before the old dimension. So in the example above the 2 goes before the dimension of size 3, giving a 2-row 3-column matrix.

If the number in brackets is greater than 1, the 2 goes after the old dimension. In the example below, 1.5 is specified. The new dimension of size 2 therefore goes after the existing dimension of size 3, giving a 3-row 2-column matrix.

                 'ABC',[1.5]'DEF'
           AD
           BE
           CF

If ŒIO is set to 0, then the examples above would be

                 'ABC',[¯0.5]'DEF'

and

                 'ABC',[0.5]'DEF'

respectively

Topic: APLX Help : Help on APL language : APL Primitives : , Catenate, Laminate

[ Previous | Next | Contents | Index ]