Slice constructor

Slice(
  1. dynamic array,
  2. dynamic n, [
  3. dynamic position
])

Creates $slice operator expression

  • array - Any valid expression as long as it resolves to an array.

  • position - Optional. Any valid expression as long as it resolves to an integer.

    • If positive, $slice determines the starting position from the start of the array. If position is greater than the number of elements, the $slice returns an empty array. *If negative, $slice determines the starting position from the end of the array. If the absolute value of the position is greater than the number of elements, the starting position is the start of the array.
  • n - Any valid expression as long as it resolves to an integer. If position is specified, n must resolve to a positive integer.

    • If positive, $slice returns up to the first n elements in the array. If the position is specified, $slice returns the first n elements starting from the position.
    • If negative, $slice returns up to the last n elements in the array. n cannot resolve to a negative number if position is specified

Implementation

Slice(array, n, [position])
    : super('slice',
          AEList([array is List ? AEList(array) : array, position, n]));