-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
array_slice
51 lines (51 loc) · 2.3 KB
/
array_slice
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
"name": "array_slice",
"type": "function",
"description": "Returns a portion of the array. The slice is defined by the start_pos and end_pos arguments.",
"arguments": [{
"arg": "array",
"description": "an array"
},
{
"arg": "start_pos",
"description": "the index of the start position of the slice (0 based). The start_pos index is included in the slice. If you use a negative start_pos, the index is counted from the end of the list (-1 based)."
},
{
"arg": "end_pos",
"description": "the index of the end position of the slice (0 based). The end_pos index is included in the slice. If you use a negative end_pos, the index is counted from the end of the list (-1 based)."
}
],
"examples": [{
"expression": "array_slice(array(1,2,3,4,5),0,3)",
"returns": "[ 1, 2, 3, 4 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),0,-1)",
"returns": "[ 1, 2, 3, 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-5,-1)",
"returns": "[ 1, 2, 3, 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),0,0)",
"returns": "[ 1 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-2,-1)",
"returns": "[ 4, 5 ]"
},
{
"expression": "array_slice(array(1,2,3,4,5),-1,-1)",
"returns": "[ 5 ]"
},
{
"expression": "array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),1,2)",
"returns": "[ 'Valmiera', 'Chugiak' ]"
},
{
"expression": "array_slice(array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),-2,-1)",
"returns": "[ 'Chugiak', 'Brighton' ]"
}
]
}