Return to homepage

DOSATO

Copyright © 2024 Sebastiaan Heins

3.3 Arrays

Functions

array SORT (array arr, function compare_function = ?)

Optionally, a compare function can be passed to sort the array in a custom way.
Sorting is based of the numerical value of the elements. (or the return value of the compare function)

array PUSH (array arr, var value)

Adds the given value to the end of the given array, and returns the array.

var POP (array arr)

Removes the last element from the given array, and returns the popped value.

var SHIFT (array arr)

Removes the first element from the given array, and returns the shifted value.

array UNSHIFT (array arr, var value)

Adds the given value to the start of the given array, and returns the array.

array SLICE (array arr, long start, long end = ?)

Returns a slice of the given array, starting at the given start index, and ending at the given end index.
If no end index is given, the slice will go to the end of the array.

array SPLICE (array arr, long start, long delete_count = ?)

Removes a number of elements from the given array, starting at the given start index, then returns a soft copy.
If no delete count is given, all elements from the start index to the end of the array will be removed.

long INDEXOF (array arr, var value)

Returns the index of the first occurence of the given value in the given array.
If the value is not found, -1 is returned.

long LASTINDEXOF (array arr, var value)

Returns the index of the last occurence of the given value in the given array.
If the value is not found, -1 is returned.

array REVERSE (array arr)

Returns a copy of the given array, with the elements in reverse order.

array FILL (var element, int amount)

Returns an array of the given amount, filled with copies of the given element.

array RANGE (long end)
array RANGE (long start, long end, long step = 1)

Returns an array of integers, starting at the given start index, ending at the given end index, and incrementing by the given step.
If no step is given, the default value of 1 is used.
If only 1 parameter is given, the default start value of 0 is used. and the given parameter is used as the end value.

array RANGEF (double end)
array RANGEF (double start, double end, double step = 1.0)

Returns an array of doubles, starting at the given start index, ending at the given end index, and incrementing by the given step.
If no step is given, the default value of 1.0 is used.
If only 1 parameter is given, the default start value of 0.0 is used. and the given parameter is used as the end value.

long COUNTER ()

Returns the current value of the counter.
The counter is a global variable that is incremented by 1 every time it is called.

long SETCOUNTER (long value)

Sets the value of the internal counter to the given value, then returns the new value.