-
Notifications
You must be signed in to change notification settings - Fork 17
/
array_find.json
171 lines (171 loc) · 5.24 KB
/
array_find.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
"id": "array_find",
"summary": "Get the index for a value in an array",
"description": "Returns the zero-based index of the first (or last) occurrence of the value specified by `value` in the array specified by `data` or `null` if there is no match. Use the parameter `reverse` to switch from the first to the last match.\n\n**Remarks:**\n\n* Use ``array_contains()`` to check if an array contains a value regardless of the position.\n* Use ``array_find_label()`` to find the index for a label.\n* All definitions for the process ``eq()`` regarding the comparison of values apply here as well. A `null` return value from ``eq()`` is handled exactly as `false` (no match).\n* Data types MUST be checked strictly. For example, a string with the content *1* is not equal to the number *1*.\n* An integer *1* is equal to a floating-point number *1.0* as `integer` is a sub-type of `number`. Still, this process may return unexpectedly `false` when comparing floating-point numbers due to floating-point inaccuracy in machine-based computation.\n* Temporal strings are treated as normal strings and MUST NOT be interpreted.\n* If the specified value is an array, object or null, the process always returns `null`. See the examples for one to find `null` values.",
"categories": [
"arrays",
"reducer"
],
"parameters": [
{
"name": "data",
"description": "List to find the value in.",
"schema": {
"type": "array",
"items": {
"description": "Any data type is allowed."
}
}
},
{
"name": "value",
"description": "Value to find in `data`. If the value is `null`, this process returns always `null`.",
"schema": {
"description": "Any data type is allowed."
}
},
{
"name": "reverse",
"description": "By default, this process finds the index of the first match. To return the index of the last match instead, set this flag to `true`.",
"schema": {
"type": "boolean"
},
"default": false,
"optional": true
}
],
"returns": {
"description": "The index of the first element with the specified value. If no element was found, `null` is returned.",
"schema": [
{
"type": "null"
},
{
"type": "integer",
"minimum": 0
}
]
},
"examples": [
{
"arguments": {
"data": [
1,
2,
3,
2,
3
],
"value": 2
},
"returns": 1
},
{
"arguments": {
"data": [
1,
2,
3,
2,
3
],
"value": 2,
"reverse": true
},
"returns": 3
},
{
"arguments": {
"data": [
"A",
"B",
"C"
],
"value": "b"
},
"returns": null
},
{
"arguments": {
"data": [
1,
2,
3
],
"value": "2"
},
"returns": null
},
{
"arguments": {
"data": [
1,
null,
2,
null
],
"value": null
},
"returns": null
},
{
"arguments": {
"data": [
[
1,
2
],
[
3,
4
]
],
"value": [
1,
2
]
},
"returns": null
},
{
"arguments": {
"data": [
[
1,
2
],
[
3,
4
]
],
"value": 2
},
"returns": null
},
{
"arguments": {
"data": [
{
"a": "b"
},
{
"c": "d"
}
],
"value": {
"a": "b"
}
},
"returns": null
}
],
"links": [
{
"rel": "example",
"type": "application/json",
"href": "https://raw.githubusercontent.com/Open-EO/openeo-community-examples/main/processes/array_find_nodata.json",
"title": "Find no-data values in arrays"
}
]
}