Syntax

	$set.filter($func)

Description

Filters set by applying the func predicate function to each of its elements. The resulting set contains only the elements that the func predicate function has evaluated as true.

Parameters

Name Type Description Mandatory Default
set Set A set to be filtered according to func. yes
func Function Predicate function to be applied to all elements of set. yes

Return value

Type: Set

A new set containing all elements from set for which the predicate function resulted true.

Examples

Number filter

	list(1, 3, 5, 3, 7, 8, 3, 9)
  .filter(x -> $x > 4)

Output: A set with the elements [5, 7, 8, 9].

For all other numbers, the function returns false.