Skip to main content

$$slice

Returns a slice of an array from a start index to end index (exclusive).

Usage​

{
"$$slice": [ /* values */ ],
"begin": /* begin */,
"end": /* end */,
}
"$$slice(<begin>,[end]):{input}"

Returns​

Same as value at specified index

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of elements
begininteger0Index of first character to slice from (if negative, counts from the end of the array)
endintegerEnd of arrayIndex of last character to slice to (if negative, counts from the end of the array)

Examples​

Input

Definition

Output

[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(1):$"
[1, 2, 3, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(2,6):$"
[2, 3, 4, 5]
[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(3,-1):$"
[3, 4, 5, 6]
[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(-2):$"
[6, 7]
[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(-3,-1):$"
[5, 6]
[0, 1, 2, 3, 4, 5, 6, 7]
"$$slice(-2,-1):$"
[6]
[0, 1, 2, 3]
"$$slice:$"
[0, 1, 2, 3]