Join

Join[list1,list2,]

concatenates lists or other expressions that share the same head.

Join[list1,list2,,n]

joins the objects at level n in each of the listi.

Details

  • The listi do not need to have head List, but must all have the same head.
  • Join works on Association objects, keeping the last value associated with any given key.
  • Join works on SparseArray objects by effectively concatenating the corresponding ordinary lists. »
  • Join[list1,list2,,n] handles ragged arrays by effectively concatenating all successive elements at level n in each of the listi. »

Examples

open allclose all

Basic Examples  (3)

Infix syntax:

Join two associations:

Scope  (4)

Join two matrices to make longer columns:

Join columns of two matrices to make longer rows:

With ragged arrays, successive elements are effectively concatenated:

The second row comes from the concatenation of nothing with {3,4}:

Join depth 3 arrays at different levels:

Generalizations & Extensions  (2)

Join expressions with any head:

Join works with SparseArray objects:

Applications  (2)

Augment a matrix by adding a row:

Augment by a column:

Make a block matrix:

This can also be done with ArrayFlatten:

Properties & Relations  (1)

Join[list1,list2,] is equivalent to Flatten[{list1,list2,},1]:

Neat Examples  (2)

Successively double a list by joining to itself:

Build up the ThueMorse sequence [more info]:

Introduced in 1988
 (1.0)
 |
Updated in 2003
 (5.0)
2007
 (6.0)
2014
 (10.0)