Publication date: 07/08/2024

Concatenate Lists

Join two or more lists into one list using Concat() or the || operator. The original lists are not changed.

The following example uses Concat() to join lists a and b:

a = {1, 2};
b = {7, 8, 9};
Concat( a, b );

{1, 2, 7, 8, 9}

The following example joins the same lists using the || operator:

{1, 2} || {7, 8, 9}

{1, 2, 7, 8, 9}

Lists of different types can be concatenated (for example, lists that contain character strings and numbers).

d = {"apples", "bananas"};
e = {"oranges", "grapes"};
f = {1, 2, 3};
Concat( d, e, f);

{"apples", "bananas", "oranges", "grapes", 1, 2, 3}

Join two or more lists and replace the first list with the combined list using Concat to() or the ||= operator. The following example performs concatenation in place using Concat to():

d = {"apples", "bananas"};
e = {"peaches", "pears"};
Concat to(d,e);
Show( d );

d = {"apples", "bananas", "peaches", "pears"}

The following example joins the same lists using the ||= operator:

d = {"apples", "bananas"};
e = {"peaches", "pears"};
d||=e;
Show( d );

d = {"apples", "bananas", "peaches", "pears"}

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).