Filter List by Matches | ARRAY_FILTER

Syntax

ARRAY_FILTER( [value], [filter] )

Parameters

value
An ARRAY to filter.

filter
A MAP or a function BLOCK to filter the items. If a MAP is used, matched values are filtered out. If a BLOCK is used, values that return TRUE are filtered out.

Return Value

Returns an array with all items in the VALUE that match the FILTER removed.

Description

Remove items matching a filter from an ARRAY.

Examples

ARRAY_FILTER([], MAP()) # returns []
# VALUE is [
#   ["a" => 1, "b" => 2],
#   ["a" => 3, "b" => 4],
#   ["a" => 1, "b" => 5]
# ]
ARRAY_FILTER(VALUE, ["a" => 1])
# returns [["a" => 3, "b" => 4]]
# VALUE is [
#   ["a" => 1, "b" => 2],
#   ["a" => 3, "b" => 4],
#   ["a" => 1, "b" => 5]
# ]
ARRAY_FILTER(VALUE, ["a" => 1, "b" => 4]) # returns [["a" => 3, "b" => 4], ["a" => 1, "b" => 5]]
# VALUE is [
#   ["a" => 1, "b" => 2],
#   ["a" => 3, "b" => 4],
#   ["a" => 1, "b" => 5]
# ]
ARRAY_FILTER(VALUE, {|item| EQUAL(MAP_GET(${item}, "a"), 1)}) # returns [["a" => 3, "b" => 4]]
ARRAY_FILTER(null, ["a" => 1]) # returns []
# VALUE is [
#   ["a" => 1, "b" => 2],
#   ["a" => 3, "b" => 4],
#   ["a" => 1, "b" => 5]
# ]
ARRAY_FILTER(VALUE, CURRENT_DATE()) # returns []