unionWith package:rio
The union of two maps. If a key occurs in both maps, the
provided function (first argument) will be used to compute the result.
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")]
The union of two maps. If a key occurs in both maps, the
provided function (first argument) will be used to compute the result.
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")]