array_shift_left
This page explains how to use the array_shift_left function in APL.
The array_shift_left function in APL shifts the elements of an array to the left by a specified number of positions. Vacated positions on the right are filled with null or an optional default_value (elements do not wrap around; to rotate elements, use array_rotate_left).
For example, array_shift_left(dynamic([1, 2, 3, 4, 5]), 2) returns [3, 4, 5, null, null].
Usage
Syntax
APL
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | The array to shift. |
shift_count | int | The number of positions to shift elements to the left. |
default_value | scalar | (Optional) The value used to fill vacated positions. Defaults to null. |
Returns
An array of the same length with elements shifted to the left by shift_count and vacated slots filled with default_value (or null).
Use case example
Reorganize span events to analyze dependencies in a different sequence.
Query
Output
JSON
JSON
This query shifts span events for frontend services to analyze the adjusted sequence.
List of related functions
- array_rotate_right: Rotates array elements to the right by a specified number of positions.
- array_rotate_left: Rotates elements of an array to the left.
- array_shift_right: Shifts array elements to the right.