InsertArrayElements()
Summary
Inserts elements into an array.
Syntax
new_array = InsertArrayElements(array my_array, integer start, array to_insert)
| Argument | Contents |
|---|---|
| my_array | The array to which elements are added |
| start | The position before which the new elements are added |
| to_insert | The array of elements to insert |
Returns
An array containing the elements of my_array, with the elements of to_insert added at the specified position.
Notes
-
If start is null, InsertArrayElements() inserts the new elements at the beginning of my_array. If start is larger than the number of elements in my_array, InsertArrayElements() inserts the new elements at the end of my_array.
-
Either my_array or to_insert, or both, can be null.
-
InsertArrayElements() does not modify my_array; it creates a new array containing additional elements.
Example
x = {1, 2, 3, 6}
y = {4, 5}
z = InsertArrayElements(x, 4, y) // z is {1, 2, 3, 4, 5, 6}
x = InsertArrayElements(x, 4, {4, 5}) // now x = z
Error Codes
| Error Type | Meaning |
|---|---|
| Error | Start is less than one |
See Also
| Function | Summary |
|---|---|
| ArrayExclude() | Excludes elements from an array |
| ArrayIntersect() | Creates an array that contains the elements of the array a that are also in array b |
| ArrayUnion() | Returns a new array containing all unique elements from arrays a and b. |
| ExcludeArrayElements() | Removes elements from an array |
| Subarray() | Extracts a subset of an array |