Difference between revisions of "Concat"
Line 27: | Line 27: | ||
Array functions | Array functions | ||
− | = Examples = | + | = Examples = |
− | Index In1 := ['a','b','c'] | + | Index In1 := ['a','b','c'] |
− | Concat( In1, ['z'] ) &rarry ['a','b','c','z'] | + | 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 = | = See Also = |
Revision as of 20:53, 22 December 2010
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.
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]
Enable comment auto-refresher