Union Of Lists With Predicate
Creates a list of unique values from two given lists, compared by predicate
Description
Creates a list of unique values from two different lists compared in the Comparator. The brick joins two lists using the Comparator to filter out undesired objects. The Comparator will go through each object in 'First list' and will compare with each object in the 'Second list'. If the Comparator returns true, the object will be included in the 'Result' list.
The 'Result' list will contain the objects from the list in which the value occurred first
Note: Both lists must be of the same type (or same Data Type)
Example:
-
Inputs
- First list =
[{ "x": 1, "y": 2 }, { "x": 2, "y": 1 }]
- Second list =
[{ "x": 1, "y": 1 }, { "x": 1, "y": 2 }]
- Comparator =
objectA 'Equals' objectB
- First list =
-
Outputs
- Result =
[{ "x": 1, "y": 2 }, { "x": 2, "y": 1 }, { "x": 1, "y": 1 }]
- Result =
In this example, the brick's ‘Comparator’ checks every object in the ‘First list’ for the presence of the same object in the ‘Second list’. Any object that matches will be returned only once in the "Result" list.
Inputs
- First list (Object): The collection to inspect. Could be in the form of List, Array and QueryResult
- Comparator (Boolean Comparator): The predicate function that compares the two objects from the list.
Inputs:
-Object A
: The left item of the list.
-Object B
: The right item of the list .
Outputs:
-result (Boolean)
: Set it totrue
ifobjects
are equal. The left object will be included in the result. - Second list (Object): The collection to inspect. Could be in the form of List, Array and QueryResult
Outputs
- Result (Object): The new list of combined values
- Error Flow (Error Flow): Triggered by providing unexpected type of the source