array_shift_right
This page explains how to use the array_shift_right function in APL.
The array_shift_right function in Axiom Processing Language (APL) shifts the elements of an array to the right by a specified number of positions. Vacated positions on the left are filled with null or an optional default_value (elements do not wrap around; to rotate elements, use array_rotate_right).
For example, array_shift_right(dynamic([1, 2, 3, 4, 5]), 2, -1) returns [-1, -1, 1, 2, 3].
Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | The input array whose elements are shifted. |
shift_count | int | The number of positions to shift elements to the right. |
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 right by shift_count and vacated slots filled with default_value (or null).
Use case example
Reorganize span events in telemetry data for visualization or debugging.
Query
Output
The query shifts span events one position to the right and fills the first position with null.
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_left: Shifts array elements to the left, filling vacated positions with
nullor a default value.