SELECT
Select specific items from list

Description

Selects items from a list that match the given criteria. Returns a list containing only the matching items, in their corresponding order.
The criteria is defined as a formula at the second parameter. The formula is evaluated with each item in the list. The formula must result in a true/false value. If true, then item will be included to the result, otherwise it will be excluded.

Function signature

1
SELECT(list: Array, filteringformula: Function) => Array
Copied!
Parameter
Description
List
List of items to filter
Filtering formula
Formula to be evaluated for each item, deciding whether to include or not to the result list

Examples

1
animals = [
2
{
3
"name": "dog",
4
"weight": 123
5
},
6
{
7
"name": "cat",
8
"weight": 48
9
},
10
{
11
"name": "rat",
12
"weight": 10
13
},
14
{
15
"name": "pig",
16
"weight": 230
17
}
18
]
19
products = [
20
{
21
"name": "Duct tape",
22
"category": "Utility"
23
},
24
{
25
"name": "Swiss army knife",
26
"category": "Tools"
27
},
28
{
29
"name": "Glue",
30
"category": "Utility"
31
}
32
]
Copied!
Formula
Return value
SELECT(animals, item.weight > 100)
[{"name":"dog","weight":123},{"name":"pig","weight":230}]
SELECT(animals, IS_ODD(index))
[{"name":"cat","weight":48},{"name":"pig","weight":230}]
SELECT<product>(products, product.category == "Utility")
[{"name":"Duct tape","category":"Utility"},{"name":"Glue","category":"Utility"}]
SELECT<product, position>(products, position < 2 && product.category == "Utility")
[{"name":"Duct tape","category":"Utility"}]
Last modified 1yr ago
Export as PDF
Copy link