intersection method

Map<K, V> intersection(
  1. Eq<K> eq,
  2. V combine(
    1. V x,
    2. V y
    ),
  3. Map<K, V> map
)

Intersect the key/value of two Map using combine where the key is the same.

Implementation

Map<K, V> intersection(
  Eq<K> eq,
  V Function(V x, V y) combine,
  Map<K, V> map,
) =>
    {
      for (var entry in map.entries)
        if (lookupEq(eq, entry.key) case Some(:var value))
          entry.key: combine(value, entry.value)
    };