Filter#
The e.filter(x, p) macro creates a new list containing only elements x from collection e where predicate p is true.
Lists#
Returns elements for which the predicate is true.
Returns an empty list if no elements match.
Filtering an empty list returns an empty list.
Maps#
When applied to a map, filter returns a list of keys that satisfy the predicate.
To filter by value, access the map within the predicate.
// input: scores = {"alice": 95, "bob": 72, "carol": 88}
scores.filter(name, scores[name] >= 80)
// result: ["alice", "carol"] (list)
An empty map returns an empty list.