SQL
Filter
**Signature:** `list_filter(list, lambda)`  
**Description:**
Constructs a list from those elements of the input list for which the lambda function returns `true`.
DuckDB must be able to cast the lambda function's return type to `BOOL`.  
**Aliases:**  
* `array_filter`
* `filter`  
**Number of parameters excluding indexes:** 1  
**Return type:** The same type as the input list  
#### Examples {#docs:sql:functions:lambda::examples}  
Filter out negative values:  
```sql
SELECT list_filter([5, -6, NULL, 7], x -> x > 0);
```  
```text
[5, 7]
```  
Divisible by 2 and 5:  
```sql
SELECT list_filter(
list_filter([2, 4, 3, 1, 20, 10, 3, 30], x -> x % 2 = 0),
y -> y % 5 = 0
);
```  
```text
[20, 10, 30]
```  
In combination with `range(...)` to construct lists:  
```sql
SELECT list_filter([1, 2, 3, 4], x -> x > #1) FROM range(4);
```  
```text
[1, 2, 3, 4]
[2, 3, 4]
[3, 4]
[4]
[]
```