Functions Index :: A :: ArraySetRange

[<< up one level]

Module:

array :: slices

Definition:

ArraySetRange(string array, string newval_array, int "start_index", int "end_index")

Description:

Assigns new values to a range of elements (subarray) of array and returns the resulting array. The function sets all elements contained in [start_index..end_index) ie the element array[end_index] is not set.

Arguments:

array: The array to set the element range (subarray) of.

newval_array: The array with the new values that array's element range will be assigned to.

"start_index" (Optional, defaults to 0): The starting index of the element range that will be set.

"end_index" (Optional, defaults to array.ArrayLen()): The ending index of the element range that will be set.

Notes and conditions on arguments relations:

1] newval_array need not have the same number of elements as the selected subarray of array. However, if that happens the new array will have different length (number of elements) from the original.

Examples:

a1 = "1,2,3,4,5,6,7,8,9"

a2 = a1.ArraySetRange("10,11,12", 3, 6)

# a2 == "1,2,3,10,11,12,7,8,9"

a3 = a1.ArraySetRange("10,11,12", 3, 4)

# a2 == "1,2,3,10,11,12,5,6,7,8,9"

a4 = a1.ArraySetRange("10,11,12", 3, 9)

# a2 == "1,2,3,10,11,12"

a5 = a1.ArraySetRange("10,11,12", 1, 6).ArraySet("-1,-2", 4, 6)

# a5 == "1,10,11,12,-1,-2,9"

 

[<< top]