pdk.flow.Array

contains functions that can be applied to pdk.core.Array variables

All functions


add

Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Arguments:

Result:

  • No variable is returned. The input array contains the new element in the defined position.

Possible exceptions

Example:

numbers :: Array<Integer> = [1,2,3] 

add(numbers, 1, 4) :: void -> 
numbers = [1,4,2,3]

addAllElements

Appends the specified array to the end of the source array

Arguments:

Result:

  • No variable is returned. The first array contains all elements from the second one.

Possible exceptions

Example

numbers1 :: Array<Integer> = [1,2,3]
numbers2 :: Array<Integer> = [4,5]

addAllElements(numbers1, numbers2) :: void -> 
numbers1 = [1,2,3,4,5]
numbers2 = [4,5]

addElement

Appends the specified element to the end of the source array.

Arguments:

Result:

  • No variable is returned. The input array contains the element.

Possible exceptions

Example

numbers :: Array<Integer> = [1,2,3]
new_element :: Integer = 4

addElement(numbers, new_element) :: void -> 
numbers = [1,2,3,4]

clear

Removes all of the elements from the input array. The array will be empty after this call returns.

Arguments:

Result:

  • No variable is returned. Input array is empty.

Possible exceptions

Example

numbers :: Array<Integer> = [1,2,3]

clear(numbers) :: void -> 
numbers = []

copy

Creates and returns a copy of the input array.

Arguments:

Result:

Example

numbers :: Array<Integer> = [1,2,3]

copy(numbers) :: Array<Integer> ->
numbers = [1,2,3]
output = [1,2,3]

intersection

Returns a new array containing all elements that are contained in both given arrays.

Arguments:

Result:

Possible exceptions

Example

numbers1 :: Array<Integer> = [1,2,3,4]
numbers2 :: Array<Integer> = [2,3,5,6]

intersection(numbers1, numbers2) :: Array<Integer> ->
numbers1 = [1,2,3,4]
numbers2 = [2,3,5,6]
output = [2,3]

partition

Returns consecutive subarrays of an array, each of the same size (the final array may be smaller). For example, partitioning an array containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer array containing two inner arrays of three and two elements, all in the original order.

Arguments:

Result:

Possible exceptions

Example

numbers :: Array<Integer> = [1,2,3,4,5,6,7,8]
size :: Integer = 3

partition(numbers, size) :: Array<Array<Integer>> ->
numbers = [1,2,3,4,5,6,7,8]
output = [ [1,2,3], [4,5,6], [7,8] ]

removeElementAtIndex

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Arguments:

Result:

  • No variable is returned. The element is removed from the list.

Possible exceptions

Example

letters :: Array<String> = ['A','B','C']
index :: Integer = 1

removeElementAtIndex(letters, index) :: Void ->
letters = ['A','C']

set

Replaces the element at the specified position in this list with the specified element and returns the element previously at the specified position.

Arguments:

Result:

  • output :: T

Possible exceptions

Example

letters :: Array<String> = ['A','B','C']
index :: Integer = 1
element :: String = 'X'

set(letters, index, element) :: String ->
letters = ['A','X','C']
output = 'B'

sortDates

Sorts array of dates in specified order.

Arguments:

Result:

  • No variable is returned. Input array is sorted.

Possible exceptions

Example

dates :: Array<Date> = [TOMORROW,YESTERDAY,TODAY]
ascending :: Boolean = true

sortDates(letters, ascending) :: Void ->
dates = [YESTERDAY,TODAY,TOMORROW]

sortNumbers

Sorts array of numbers in specified order.

Arguments:

Result:

  • No variable is returned. Input array is sorted.

Possible exceptions

Example

numebrs :: Array<Number> = [3.2,2,8]
ascending :: Boolean = true

sortNumbers(numebrs, ascending) :: Void ->
numebrs = [2,3.2,8]

sortStrings

Sorts array of string in specified order.

Arguments:

Result:

  • No variable is returned. Input array is sorted.

Possible exceptions

Example

strings :: Array<String> = ['B','C','A']
ascending :: Boolean = true

sortStrings(strings, ascending) :: Void ->
strings = ['A','B','C']

sum

Returns the sum of the given arrays. This is their intersection subtracted from their union.

Arguments:

Result:

Possible exceptions

Example

array1 :: Array<Integer> = [1,3,4,5,7]
array2 :: Array<Integer> = [2,3,5,6]

sum(array1, array2) :: Array<Integer> ->
array1 = [1,3,4,5,7]
array2 = [2,3,5,6]
output = [1,4,7,2,3,5,6]

Last updated