Difference between revisions of "Concat"

Line 19: Line 19:
 
concatenates (i.e., joins) arrays A and B, with the new result indexed by K.  You must provide an index K whose length is the sum of the lengths of I and J.  Often the index K is obtained using the first form of concatenate.
 
concatenates (i.e., joins) arrays A and B, with the new result indexed by K.  You must provide an index K whose length is the sum of the lengths of I and J.  Often the index K is obtained using the first form of concatenate.
  
(new to 4.1) You can omit the K parameter:
+
''(new to 4.1)'' You can omit the K parameter:
 
  Concat(A,B,I,J)
 
  Concat(A,B,I,J)
 
when you do so, the function creates a new local index named K for the result.
 
when you do so, the function creates a new local index named K for the result.
 +
 +
When using the five parameter form, <code>Concat(A,B,I,J,K)</code>, the index element values don't impact the result, so it doesn't matter if the elements of <code>K</code> are also elements of <code>I</code> or <code>J</code>, nor does it matter what order the index elements of <code>K</code> appear in.  All that matters is that the number of elements in <code>K</code> is the number of elements of <code>I</code> plus the number of elements in <code>J</code>.  The positional ordering of the slices of each array are not altered -- the result consists of all the elements of <code>A</code> followed by all the elements of <code>B</code>.
 +
 +
When <code>A</code> (or <code>B</code>) is implicitly indexed (for example, if it is a list or a single number), you can omit the index parameter.  For example:
 +
Concat([0],B,,J,K)
 +
would prepend a column of zeroes to <code>B</code>.
  
 
= Library =
 
= Library =

Revision as of 21:31, 6 January 2013


Concat(A,B,I,J,K)

Concatenates lists or arrays.

When A and B are 1-D arrays,

Concat(A,B)

returns a list (1-D array) consisting of their elements. This form is often used to concatentate two indexes to obtain the elements for a third index.

When A and B are 1-D arrays with a common index

Concat([A],[B])

returns a 2-D array with two columns. Notice square brackets surrounding the variables. If only two parameters are used, column index is .K.

When A and B are arbitrary arrays, where A has index I and B has index J, then

Concat(A,B,I,J,K)

concatenates (i.e., joins) arrays A and B, with the new result indexed by K. You must provide an index K whose length is the sum of the lengths of I and J. Often the index K is obtained using the first form of concatenate.

(new to 4.1) You can omit the K parameter:

Concat(A,B,I,J)

when you do so, the function creates a new local index named K for the result.

When using the five parameter form, Concat(A,B,I,J,K), the index element values don't impact the result, so it doesn't matter if the elements of K are also elements of I or J, nor does it matter what order the index elements of K appear in. All that matters is that the number of elements in K is the number of elements of I plus the number of elements in J. The positional ordering of the slices of each array are not altered -- the result consists of all the elements of A followed by all the elements of B.

When A (or B) is implicitly indexed (for example, if it is a list or a single number), you can omit the index parameter. For example:

Concat([0],B,,J,K)

would prepend a column of zeroes to B.

Library

Array functions

Examples

Index In1 := ['a','b','c']
Concat( In1, ['z'] ) &rarry ['a','b','c','z']
index I := [1, 2];
index J := ['a', 'b'];
index K := concat(J, 'c');
var A := Array( I, J, 1 );
var B := Array( I, 2 );
Concat( A, [B], J, , K)

Result:
   a  b  c
1| [1, 1, 2
2|  1, 1, 2]

See Also

Comments


You are not allowed to post comments.