发布日期: 09/18/2023

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"}

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).