ArrayTools

https://github.com/theonetruenerd/VenusPackages/blob/main/ArrayTools.pkg

The ArrayTools library provides the following functions:

ArraySeqVLookup(array i_arraySequencesA, array i_arrayValuesB, variable i_varCondition, array o_arraySequencesC)

Given 2 arrays A (Sequences) and B (Values) with same size Retrieve all the sequences in A where B = input value A(seq1, seq2, seq3,seq4,seq5, seq6, …) B(1, 2, 3, 1, 2, 3, …)

Get from A all elements where B = 1 C(seq1, seq4, …)

Parameters:
  • i_arraySequencesA (Array of sequences) – The input array of sequences to filter

  • i_arrayValuesB (Array of variables) – The input array of variables to act as a filter

  • i_varCondition (Variable) – The input value of the variable which is to be selected

  • o_arraySequencesC (Array of sequences) – The output array of the sequences whose index matches the indices in which the the value of the variable is equal to the filter

Returns:

None

Return type:

N/A

ArrayVLookup(array i_arrayValuesA, array i_arrayValuesB, variable i_varCondition, array o_arrayValuesC)

Given 2 arrays of values A and B with same size Retrieve all the elements in B where A = input value

A(100, 20, 15, 45, 42, 1, …) B(1, 2, 3, 1, 2, 3, …)

Get from A all elements where B = 1 C(100, 15, …)

Parameters:
  • i_arrayValuesA (Array of variables) – The input array of variables to filter

  • i_arrayValuesB (Array of variables) – The input array of variables to act as a filter

  • i_varCondition (Variable) – The input value of the variable which is to be selected

  • o_arrayValuesC (Array of variables) – The output array of the variables whose index matches the indices in which the value of the variable is equal to the filter

Returns:

None

Return type:

N/A

ConvertArrayOfNumericIntegersToString(array i_arr1_int, array o_arr1_str)

Converts all the numeric integers within an array to strings.

Parameters:
  • i_arr1_int (Array of variables) – The input array containing the integers to be converted

  • o_arr1_str (Array of variables) – The output array containing the strings

Returns:

None

Return type:

N/A

ConvertArrayOfNumericStringsToIntegers(array i_arr1_str, array o_arr1_int)

Converts all the numeric strings within an array to integers.

Parameters:
  • i_arr1_str (Array of variables) – The input array containing the strings to be converted

  • o_arr1_int (Array of variables) – The output array containing the integers

Returns:

None

Return type:

N/A

Lookup(array array, variable item)

Looks up a value within an array, outputting a 1-based index of the value if found in the array, and a 0 if the value isn’t found.

Parameters:
  • array (Array) – The input array to be searched

  • item (Variable) – The variable to be searched for

Returns:

None

Return type:

N/A

Sort3ArraysByNumericAscendingOrder(array io_array1, array io_array2, array io_array3)

Sorts 3 arrays by numeric ascending order. io_array1 must contain only numeric values; this one will be sorted and then the other arrays will update to match the new order of io_array1.

Parameters:
  • io_array1 (Array) – The first of the arrays to be sorted, which must contain only numeric values.

  • io_array2 (Array) – The second of the arrays to be sorted, which can contain any values.

  • io_array3 (Array) – The third of the arrays to be sorted, which can contain any values.

Returns:

None

Return type:

N/A

Update_Value_in_Array(array i_array, variable i_value, variable i_index)

Overwrites a value in the array at a specified index.

Parameters:
  • i_array (Array) – The array in which the value will be changed.

  • i_value (Variable) – The new value to be inserted into the array.

  • i_index (Variable) – The 1-based index of the position in the array to be overwritten.

Returns:

None

Return type:

N/A

get_distinct_from_array(array i_arr, array o_arr)

Gets all the values in an array that only appear once.

Parameters:
  • i_arr (Array) – The input array to be searched.

  • o_arr – The new output array containing the values which only appear once.

Returns:

None

Return type:

N/A

mergeArrays(array array1, array array2, array array3)

Concatenates two arrays and outputs the result into a third array.

Parameters:
  • array1 (Array) – The first array of interest.

  • array2 (Array) – The second array of interest.

  • array3 (Array) – The resulting array of values.

Returns:

None

Return type:

N/A

removeValueFromArray_basedOnIndex(array i_array_elements, variable i_index_to_remove)

Removes a value from an array at the specified index.

Parameters:
  • i_array_elements (Array) – The array from which an item is to be removed.

  • i_index_to_remove (Variable) – The 1-based index of the array from which the item is to be removed.

Returns:

None

Return type:

N/A