$$slice
Gets a slice of an array by indices (negative begin index will slice from the end)
Usage​
{
"$$slice": /* Array to fetch from */,
"begin": /* integer */,
"end": null /* integer */
}
"$$slice(<begin>,[end]):{input}"
note
Concrete values in the usage example are default values.
Returns​
Same type as input array
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | array | Yes | Array to fetch from | |
begin | integer | Yes | Index of first element to slice from (if negative, counts from the end of the array) | |
end | integer | Infinity | Index of last element 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():$"
[
0,
1,
2,
3,
4,
5,
6,
7
]
[
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,
4,
5,
6,
7
]
{
"$$slice": "$"
}
[
0,
1,
2,
3,
4,
5,
6,
7
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": 1
}
[
1,
2,
3,
4,
5,
6,
7
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": 2,
"end": 6
}
[
2,
3,
4,
5
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": 3,
"end": -1
}
[
3,
4,
5,
6
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": -2
}
[
6,
7
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": -3,
"end": -1
}
[
5,
6
]
[
0,
1,
2,
3,
4,
5,
6,
7
]
{
"$$slice": "$",
"begin": -2,
"end": -1
}
[
6
]