Join
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 all close allBasic Examples (3)
Scope (4)
Join two matrices to make longer columns:
Join[{{a, b}, {c, d}}, {{1, 2}, {3, 4}}]Join columns of two matrices to make longer rows:
Join[{{a, b}, {c, d}}, {{1, 2}, {3, 4}}, 2]With ragged arrays, successive elements are effectively concatenated:
Join[{{1}, {5, 6}}, {{2, 3}, {7}}, {{4}, {8}}, 2]The second row comes from the concatenation of nothing with {3,4}:
Join[{{x}}, {{1, 2}, {3, 4}}, 2]Join depth 3 arrays at different levels:
aa = Array[Subscript[a, #]&, {2, 2, 2}];
bb = Array[Subscript[b, #]&, {2, 2, 2}];Join[aa, bb]Join[aa, bb, 2]Join[aa, bb, 3]Generalizations & Extensions (2)
Join expressions with any head:
Join[f[a, b, c], f[x, y], f[u, v, w]]Join works with SparseArray objects:
SparseArray[Range[5]]Join[%, %, %]Applications (2)
Augment a matrix by adding a row:
Join[IdentityMatrix[3], {{1, 2, 3}}]//MatrixFormJoin[IdentityMatrix[3], Transpose[{{1, 2, 3}}], 2]//MatrixFormJoin[Join[(| | | |
| :- | :- | :- |
| a1 | a1 | a1 |
| a2 | a2 | a2 |
| a3 | a3 | a3 |), (| | | |
| :- | :- | :- |
| b1 | b1 | b1 |
| b2 | b2 | b2 |
| b3 | b3 | b3 |), 2], Join[(| | | |
| :- | :- | :- |
| c1 | c1 | c1 |
| c2 | c2 | c2 |
| c3 | c3 | c3 |), (| | | |
| :- | :- | :- |
| d1 | d1 | d1 |
| d2 | d2 | d2 |
| d3 | d3 | d3 |), 2]]//MatrixFormThis can also be done with ArrayFlatten:
ArrayFlatten[(| | |
| :-- | :-- |
| (\| \| \| \| \| :- \| :- \| :- \| \| a1 \| a1 \| a1 \| \| a2 \| a2 \| a2 \| \| a3 \| a3 \| a3 \|) | (\| \| \| \| \| :- \| :- \| :- \| \| b1 \| b1 \| b1 \| \| b2 \| b2 \| b2 \| \| b3 \| b3 \| b3 \|) |
| (\| \| \| \| \| :- \| :- \| :- \| \| c1 \| c1 \| c1 \| \| c2 \| c2 \| c2 \| \| c3 \| c3 \| c3 \|) | (\| \| \| \| \| :- \| :- \| :- \| \| d1 \| d1 \| d1 \| \| d2 \| d2 \| d2 \| \| d3 \| d3 \| d3 \|) |)]//MatrixFormProperties & Relations (1)
Neat Examples (2)
Successively double a list by joining to itself:
NestList[Join[#, #]&, {x}, 4]Build up the Thue–Morse sequence [more info]:
NestList[Join[#, 1 - #]&, {1}, 5]See Also
Catenate Union StringJoin Append Prepend PadLeft Flatten ArrayFlatten ArrayPad
Function Repository: AppendColumn PrependColumn JoinMap
Tech Notes
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2007 (6.0) ▪ 2014 (10.0)
Text
Wolfram Research (1988), Join, Wolfram Language function, https://reference.wolfram.com/language/ref/Join.html (updated 2014).
CMS
Wolfram Language. 1988. "Join." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Join.html.
APA
Wolfram Language. (1988). Join. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Join.html
BibTeX
@misc{reference.wolfram_2026_join, author="Wolfram Research", title="{Join}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Join.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_join, organization={Wolfram Research}, title={Join}, year={2014}, url={https://reference.wolfram.com/language/ref/Join.html}, note=[Accessed: 12-June-2026]}