Description
Combines two lists and returns a new list containing all unique elements from both lists. Duplicates are automatically removed, treating the inputs as sets.Syntax
Parameters
Returns
Type: list A new list containing all unique elements from both input lists. The order is not guaranteed.Examples
Example 1: Basic Union
Example 2: Combining Tags from Multiple Nodes
Example 3: Merging User Interests
Example 4: Finding All Related Categories
Notes
- Automatically removes duplicates from the result
- Works with any comparable data types
- Order of elements in the result is not guaranteed
- Equivalent to mathematical set union operation
- Both lists are spread and deduplicated using Set
See Also
- coll.intersection - Find common elements between lists
- sim.jaccard - Calculate similarity between sets
Frequently Asked Questions
Does flex.coll.union remove duplicates?
Does flex.coll.union remove duplicates?
Yes. The union function combines all input lists and returns only unique elements.
Can I pass more than two lists to union?
Can I pass more than two lists to union?
Yes. You can pass multiple lists as arguments to combine them all into a single deduplicated result.