filter
Use filter to filter a list of elements by applying the specified apply function to each element in the list.
For each element in the list, the apply function should return true or flase to identify the elements that should be included in the filtered list.
Each element that returns a result of true from the apply function is included in the resulting list with its original value.
With the filter function, you can include elements in a list based on a specific condition.
Basic syntax
To filter a list by applying a function to each element, use the following syntax:
(filter apply [elements])
Arguments
Use the following arguments to specify the function and list for the filter Pact function:
| Argument | Type | Description |
|---|---|---|
apply | function | Specifies the function to apply to each element of the list. The return value for the function must be a Boolean (true or false) to identify elements to be included in the resulting list. |
elements | [any] | Specifies the list of elements to filter. The elements in the list can be any data type. |