union

The union function returns the list union of the two lists. It is a special case of unionBy, which allows the programmer to supply their own equality test.

Examples

>>> "dog" `union` "cow"
"dogcw"
If equal elements are present in both lists, an element from the first list will be used. If the second list contains equal elements, only the first one will be retained:
>>> import Data.Semigroup(Arg(..))

>>> union [Arg () "dog"] [Arg () "cow"]
[Arg () "dog"]

>>> union [] [Arg () "dog", Arg () "cow"]
[Arg () "dog"]
However if the first list contains duplicates, so will the result:
>>> "coot" `union` "duck"
"cootduk"

>>> "duck" `union` "coot"
"duckot"
union is productive even if both arguments are infinite.
>>> [0, 2 ..] `union` [1, 3 ..]
[0,2,4,6,8,10,12..
The (left-biased) union of two maps. It prefers the first map 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")]
The union of two sets.
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")]
The union of two sets, preferring the first set when equal elements are encountered.
The (left-biased) union of two maps. It prefers the first map when duplicate keys are encountered, i.e. (union == unionWith const).
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]
Union two graphs together.
Unify two equivalence classes, so that they share a canonical element. Keeps the descriptor of point2.
The (left-biased) union of two maps. It prefers the first map 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")]
The union of two sets.
Return the union of two non-empty lists. 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.
(1 :| [3, 5, 3]) `union` (4 :| [5, 3, 5, 2]) == 1 :| [3, 5, 3, 4, 2]
Form the smallest bounding box containing the given two bound union. This function is just an alias for mappend.
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.
Get the union of two containers.