-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrearrange.json
112 lines (112 loc) · 2.69 KB
/
rearrange.json
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
"id": "rearrange",
"summary": "Sort an array based on a permutation",
"description": "Rearranges an array based on a ranked list of element positions in the original list (i.e., a permutation). The positions must be zero-based. The process ``order()`` can compute such a permutation.",
"categories": [
"arrays",
"sorting"
],
"parameters": [
{
"name": "data",
"description": "The array to rearrange.",
"schema": {
"type": "array",
"items": {
"description": "Any data type is allowed."
}
}
},
{
"name": "order",
"description": "The permutation used for rearranging.",
"schema": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
}
}
],
"returns": {
"description": "The rearranged array.",
"schema": {
"type": "array",
"items": {
"description": "Any data type is allowed."
}
}
},
"examples": [
{
"title": "Reverse a list",
"arguments": {
"data": [
5,
4,
3
],
"order": [
2,
1,
0
]
},
"returns": [
3,
4,
5
]
},
{
"title": "Remove two elements",
"arguments": {
"data": [
5,
4,
3,
2
],
"order": [
1,
3
]
},
"returns": [
4,
2
]
},
{
"title": "Swap two elements",
"arguments": {
"data": [
5,
4,
3,
2
],
"order": [
0,
2,
1,
3
]
},
"returns": [
5,
3,
4,
2
]
}
],
"links": [
{
"rel": "about",
"href": "http://mathworld.wolfram.com/Permutation.html",
"title": "Permutation explained by Wolfram MathWorld"
}
]
}