union package:rio

The union of two maps. If a key occurs in both maps, the mapping from the first will be the mapping in the result.

Examples

>>> union (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])
fromList [(1,'a'),(2,'b'),(3,'d')]
Construct a set containing all elements from both sets. To obtain good performance, the smaller set must be presented as the first argument.
>>> union (fromList [1,2]) (fromList [2,3])
fromList [1,2,3]
The union function returns the list union of the two lists. For example,
>>> "dog" `union` "cow"
"dogcw"
Duplicates, and elements of the first list, are removed from the the second list, but if the first list contains duplicates, so will the result. It is a special case of unionBy, which allows the programmer to supply their own equality test.
O(m*log(n/m + 1)), m <= n. The expression (union t1 t2) takes the left-biased union of t1 and t2. It prefers t1 when duplicate keys are encountered, i.e. (union == unionWith const).
union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]
O(m*log(n/m + 1)), m <= n. The union of two sets, preferring the first set when equal elements are encountered.
The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
Construct a set containing all elements from a list of sets.
Construct a set containing all elements from a list of sets.
The unionBy function is the non-overloaded version of union.
O(m*log(n/m + 1)), m <= n. Union with a combining function.
unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
O(m*log(n/m + 1)), m <= n. Union with a combining function.
let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value
unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]
The union of a list of maps: (unions == foldl union empty).
unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
== fromList [(3, "b"), (5, "a"), (7, "C")]
unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
== fromList [(3, "B3"), (5, "A3"), (7, "C")]
The union of a list of maps, with a combining operation: (unionsWith f == foldl (unionWith f) empty).
unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
== fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
The union of the sets in a Foldable structure : (unions == foldl union empty).