UNPKG

extra-map

Version:

A group of functions for working with Maps.<br>

612 lines (611 loc) • 24.9 kB
import type { MapFunction as IterableMapFunction } from "@nodef/extra-iterable"; /** Entries is a list of key-value pairs, with unique keys. */ export type Entries<K, V> = Iterable<[K, V]>; /** Lists is a pair of key list and value list, with unique keys. */ export type Lists<K, V> = [Iterable<K>, Iterable<V>]; /** * Handle reading of a single value. * @returns value */ export type ReadFunction<V> = () => V; /** * Handle combining of two values. * @param a a value * @param b another value * @returns combined value */ export type CombineFunction<V> = (a: V, b: V) => V; /** * Handle comparison of two values. * @param a a value * @param b another value * @returns a<b: -ve, a=b: 0, a>b: +ve */ export type CompareFunction<V> = (a: V, b: V) => number; /** * Handle processing of values in a map. * @param v value in map * @param k key of value in map * @param x map containing the value */ export type ProcessFunction<K, V> = (v: V, k: K, x: Map<K, V>) => void; /** * Handle selection of values in a map. * @param v value in map * @param k key of value in map * @param x map containing the value * @returns selected? */ export type TestFunction<K, V> = (v: V, k: K, x: Map<K, V>) => boolean; /** * Handle transformation of a value to another. * @param v value in map * @param k key of value in map * @param x map containing the value * @returns transformed value */ export type MapFunction<K, V, W> = (v: V, k: K, x: Map<K, V> | null) => W; /** * Handle reduction of multiple values into a single value. * @param acc accumulator (temporary result) * @param v value in map * @param k key of value in map * @param x map containing the value * @returns reduced value */ export type ReduceFunction<K, V, W> = (acc: W, v: V, k: K, x: Map<K, V>) => W; /** * Handle ending of a combined map. * @param dones iᵗʰ map done? * @returns combined map done? */ export type EndFunction = (dones: boolean[]) => boolean; /** * Check if value is a map. * @param v value * @returns v is a map? */ export declare function is(v: unknown): v is Map<unknown, unknown>; /** * List all keys. * @param x a map * @returns k₀, k₁, ... | [kᵢ, vᵢ] ∈ x */ export declare function keys<K, V>(x: Map<K, V>): IterableIterator<K>; /** * List all values. * @param x a map * @returns v₀, v₁, ... | [kᵢ, vᵢ] ∈ x */ export declare function values<K, V>(x: Map<K, V>): IterableIterator<V>; /** * List all key-value pairs. * @param x a map * @returns [k₀, v₀], [k₁, v₁], ... | [kᵢ, vᵢ] ∈ x */ export declare function entries<K, V>(x: Map<K, V>): IterableIterator<[K, V]>; /** * Convert entries to map. * @param x entries * @returns x as map */ export declare function from<K, V>(x: Entries<K, V>): Map<K, V>; export { from as fromEntries }; /** * Convert entries to map. * @param x entries (updateable is map!) * @returns x as map */ export declare function from$<K, V>(x: Entries<K, V>): Map<K, V>; export { from$ as fromEntries$ }; /** * Convert lists to map. * @param x lists, i.e. [keys, values] * @returns x as map */ export declare function fromLists<K, V>(x: Lists<K, V>): Map<K, V>; /** * Create a map from keys. * @param x keys * @param fm map function for values (v, i, x) * @returns x as map */ export declare function fromKeys<K, V = K>(x: Iterable<K>, fm?: IterableMapFunction<K, K | V> | null): Map<K, K | V>; /** * Create a map from values. * @param x values * @param fm map function for keys (v, i, x) * @returns x as map */ export declare function fromValues<V, K = V>(x: Iterable<V>, fm?: IterableMapFunction<V, V | K> | null): Map<V | K, V>; /** * Compare two maps. * @param x a map * @param y another map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns x=y: 0, otherwise: -ve/+ve */ export declare function compare<K, V, W = V>(x: Map<K, V>, y: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): number; /** * Check if two maps are equal. * @param x a map * @param y another map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns x = y? */ export declare function isEqual<K, V, W = V>(x: Map<K, V>, y: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): boolean; /** * Find the size of a map. * @param x a map * @returns |x| */ export declare function size<K, V>(x: Map<K, V>): number; export { size as length }; /** * Check if a map is empty. * @param x a map * @returns |x| = 0? */ export declare function isEmpty<K, V>(x: Map<K, V>): boolean; /** * Get value at key. * @param x a map * @param k key * @returns x[k] */ export declare function get<K, V>(x: Map<K, V>, k: K): V | undefined; /** * Get values at keys. * @param x a map * @param ks keys * @returns [x[k₀], x[k₁], ...] | [k₀, k₁, ...] = ks */ export declare function getAll<K, V>(x: Map<K, V>, ks: K[]): (V | undefined)[]; /** * Get value at path in a nested map. * @param x a nested map * @param p path * @returns x[k₀][k₁][...] | [k₀, k₁, ...] = p */ export declare function getPath<K>(x: Map<K, unknown>, p: K[]): unknown; /** * Check if nested map has a path. * @param x a nested map * @param p path * @returns x[k₀][k₁][...] exists? | [k₀, k₁, ...] = p */ export declare function hasPath<K>(x: Map<K, unknown>, p: K[]): boolean; /** * Set value at key. * @param x a map * @param k key * @param v value * @returns x' | x' = x; x'[k] = v */ export declare function set<K, V>(x: Entries<K, V>, k: K, v: V): Map<K, V>; /** * Set value at key. * @param x a map (updated) * @param k key * @param v value * @returns x | x[k] = v */ export declare function set$<K, V>(x: Map<K, V>, k: K, v: V): Map<K, V>; /** * Set value at path in a nested map. * @param x a nested map (updated) * @param p path * @param v value * @returns x | x[k₀][k₁][...] = v; [k₀, k₁, ...] = p */ export declare function setPath$<K>(x: Map<K, unknown>, p: K[], v: unknown): Map<K, unknown>; /** * Exchange two values. * @param x a map * @param k a key * @param l another key * @returns x' | x' = x; x'[k] = x[l]; x'[l] = x[k] */ export declare function swap<K, V>(x: Entries<K, V>, k: K, l: K): Map<K, V>; /** * Exchange two values. * @param x a map (updated) * @param k a key * @param l another key * @returns x | x[i] ↔ x[j] */ export declare function swap$<K, V>(x: Map<K, V>, k: K, l: K): Map<K, V>; /** * Remove value at key. * @param x a map * @param k key * @returns x \\: [k] */ export declare function remove<K, V>(x: Entries<K, V>, k: K): Map<K, V>; /** * Remove value at key. * @param x a map (updated) * @param k key * @returns x = x \\: [k] */ export declare function remove$<K, V>(x: Map<K, V>, k: K): Map<K, V>; /** * Remove value at path in a nested map. * @param x a nested map (updated) * @param p path * @returns x = x \\: [k₀][k₁][...] | [k₀, k₁, ...] = p */ export declare function removePath$<K>(x: Map<K, unknown>, p: K[]): Map<K, unknown>; /** * Count values which satisfy a test. * @param x a map * @param ft test function (v, k, x) * @returns Σtᵢ | tᵢ = 1 if ft(vᵢ) else 0; [kᵢ, vᵢ] ∈ x */ export declare function count<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): number; /** * Count occurrences of values. * @param x a map * @param fm map function (v, k, x) * @returns Map \{value ⇒ count\} */ export declare function countAs<K, V, W = V>(x: Map<K, V>, fm?: MapFunction<K, V, V | W> | null): Map<V | W, number>; /** * Find smallest value. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns v | v ≤ vᵢ; [kᵢ, vᵢ] ∈ x */ export declare function min<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): V; /** * Find smallest entry. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [min_key, min_value] */ export declare function minEntry<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [K, V]; /** * Find largest value. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns v | v ≥ vᵢ; [kᵢ, vᵢ] ∈ x */ export declare function max<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): V; /** * Find largest entry. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [max_key, max_value] */ export declare function maxEntry<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [K, V]; /** * Find smallest and largest values. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [min_value, max_value] */ export declare function range<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [V, V]; /** * Find smallest and largest entries. * @param x a map * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [min_entry, max_entry] */ export declare function rangeEntries<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [[K, V], [K, V]]; /** * Get first entry from map (default order). * @param x a map * @param ed default entry * @returns [k₀, v₀] if x ≠ Φ else ed | [k₀, v₀] ∈ x */ export declare function head<K, V>(x: Entries<K, V>, ed?: [K | undefined, V | undefined]): [K | undefined, V | undefined]; /** * Get a map without its first entry (default order). * @param x a map * @returns x \\ \{[k₀, v₀]\} if x ≠ Φ else x | [k₀, v₀] ∈ x */ export declare function tail<K, V>(x: Map<K, V>): Map<K, V>; /** * Keep first n entries only (default order). * @param x a map * @param n number of entries [1] * @returns \{[k₀, v₀], [k₁, v₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[k₀, v₀], [k₁, v₁], ...\}| ≤ n */ export declare function take<K, V>(x: Map<K, V>, n?: number): Map<K, V>; /** * Keep first n entries only (default order). * @param x a map (updated) * @param n number of entries [1] * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[k₀, v₀], [k₁, v₁], ...\}| ≤ n */ export declare function take$<K, V>(x: Map<K, V>, n?: number): Map<K, V>; /** * Remove first n entries (default order). * @param x a map * @param n number of entries [1] * @returns \{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\}| ≤ max(|x| - n, 0) */ export declare function drop<K, V>(x: Map<K, V>, n?: number): Map<K, V>; /** * Remove first n entries (default order). * @param x a map (updated) * @param n number of entries [1] * @returns x = \{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\}| ≤ max(|x| - n, 0) */ export declare function drop$<K, V>(x: Map<K, V>, n?: number): Map<K, V>; /** * List all possible subsets. * @param x a map * @param n number of entries [-1 ⇒ any] * @returns entries selected by bit from 0..2^|x| if n<0; only of length n otherwise */ export declare function subsets<K, V>(x: Map<K, V>, n?: number): IterableIterator<Map<K, V>>; /** * Pick an arbitrary key. * @param x a map * @param fr random number generator ([0, 1)) * @returns kᵢ | [kᵢ, vᵢ] ∈ x */ export declare function randomKey<K, V>(x: Map<K, V>, fr?: ReadFunction<number>): K; export { randomKey as key }; /** * Pick an arbitrary entry. * @param x a map * @param fr random number generator ([0, 1)) * @returns [kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x */ export declare function randomEntry<K, V>(x: Entries<K, V>, fr?: ReadFunction<number>): [K, V]; export { randomEntry as entry }; /** * Pick an arbitrary subset. * @param x a map * @param n number of entries [-1 ⇒ any] * @param fr random number generator ([0, 1)) * @returns \{[kᵢ, vᵢ], [kⱼ, vⱼ], ...\} | [kᵢ, vᵢ], [kⱼ, vⱼ], ... ∈ x; |\{[kᵢ, vᵢ], [kⱼ, vⱼ], ...\}| = |x| if n<0 else n */ export declare function randomSubset<K, V>(x: Map<K, V>, n?: number, fr?: ReadFunction<number> | null): Map<K, V>; export { randomSubset as subset }; /** * Check if map has a key. * @param x a map * @param k search key * @returns [k, *] ∈ x? */ export declare function has<K, V>(x: Map<K, V>, k: K): boolean; export { has as hasKey }; /** * Check if map has a value. * @param x a map * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [*, v] ∈ x? */ export declare function hasValue<K, V, W = V>(x: Map<K, V>, v: V, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): boolean; /** * Check if map has an entry. * @param x a map * @param e search entry ([k, v]) * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [k, v] ∈ x? | [k, v] = e */ export declare function hasEntry<K, V, W = V>(x: Map<K, V>, e: [K, V], fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): boolean; /** * Check if map has a subset. * @param x a map * @param y search subset * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns y ⊆ x? */ export declare function hasSubset<K, V, W = V>(x: Map<K, V>, y: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): boolean; /** * Find first value passing a test (default order). * @param x a map * @param ft test function (v, k, x) * @returns first v | ft(v) = true; [k, v] ∈ x */ export declare function find<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): V | undefined; /** * Find values passing a test. * @param x a map * @param ft test function (v, k, x) * @returns [v₀, v₁, ...] | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x */ export declare function findAll<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): V[]; /** * Find key of an entry passing a test. * @param x a map * @param ft test function (v, k, x) * @returns key of entry */ export declare function search<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): K | undefined; /** * Find keys of entries passing a test. * @param x a map * @param ft test function (v, k, x) * @returns keys of entries */ export declare function searchAll<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): K[]; /** * Find a key with given value. * @param x a map * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns key of value */ export declare function searchValue<K, V, W = V>(x: Map<K, V>, v: V, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): K | undefined; /** * Find keys with given value. * @param x a map * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns keys of value */ export declare function searchValueAll<K, V, W = V>(x: Map<K, V>, v: V, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): K[]; /** * Call a function for each value. * @param x a map * @param fp process function (v, k, x) */ export declare function forEach<K, V>(x: Map<K, V>, fp: ProcessFunction<K, V>): void; /** * Check if any value satisfies a test. * @param x a map * @param ft test function (v, k, x) * @returns true if ft(vᵢ) = true for some [kᵢ, vᵢ] ∈ x */ export declare function some<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): boolean; /** * Check if all values satisfy a test. * @param x a map * @param ft test function (v, k, x) * @returns true if ft(vᵢ) = true for all [kᵢ, vᵢ] ∈ x */ export declare function every<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): boolean; /** * Transform values of a map. * @param x a map * @param fm map function (v, k, x) * @returns \{[k₀, fm(v₀)], [k₁, fm(v₁)], ...\} | [kᵢ, vᵢ] ∈ x */ export declare function map<K, V, W = V>(x: Map<K, V>, fm: MapFunction<K, V, V | W>): Map<K, V | W>; /** * Transform values of a map. * @param x a map (updated) * @param fm map function (v, k, x) * @returns x = \{[k₀, fm(v₀)], [k₁, fm(v₁)], ...\} | [kᵢ, vᵢ] ∈ x */ export declare function map$<K, V>(x: Map<K, V>, fm: MapFunction<K, V, V>): Map<K, V>; /** * Reduce values of set to a single value. * @param x a map * @param fr reduce function (acc, v, k, x) * @param acc initial value * @returns fr(fr(acc, v₀), v₁)... | fr(acc, v₀) = v₀ if acc not given */ export declare function reduce<K, V, W = V>(x: Map<K, V>, fr: ReduceFunction<K, V, V | W>, acc?: V | W): V | W; /** * Keep entries which pass a test. * @param x a map * @param ft test function (v, k, x) * @returns \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x */ export declare function filter<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>; /** * Keep entries which pass a test. * @param x an map (updated) * @param ft test function (v, k, x) * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x */ export declare function filter$<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>; /** * Keep values at given keys. * @param x a map * @param ks keys * @returns \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x */ export declare function filterAt<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>; /** * Keep values at given keys. * @param x a map (updated) * @param ks keys * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x */ export declare function filterAt$<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>; /** * Discard entries which pass a test. * @param x a map * @param ft test function (v, k, x) * @returns \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x */ export declare function reject<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>; /** * Discard entries which pass a test. * @param x a map (updated) * @param ft test function (v, k, x) * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x */ export declare function reject$<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>; /** * Discard values at given keys. * @param x a map * @param ks keys * @returns \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x */ export declare function rejectAt<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>; /** * Discard values at given keys. * @param x a map (updated) * @param ks keys * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x */ export declare function rejectAt$<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>; /** * Flatten nested map to given depth. * @param x a nested map * @param n maximum depth [-1 ⇒ all] * @param fm map function (v, k, x) * @param ft test function for flatten (v, k, x) [is] * @returns flat map */ export declare function flat<K>(x: Map<K, unknown>, n?: number, fm?: MapFunction<K, unknown, unknown> | null, ft?: TestFunction<K, unknown> | null): Map<K, unknown>; /** * Flatten nested map, based on map function. * @param x a nested map * @param fm map function (v, k, x) * @param ft test function for flatten (v, k, x) [is] * @returns flat map */ export declare function flatMap<K>(x: Map<K, unknown>, fm?: MapFunction<K, unknown, unknown> | null, ft?: TestFunction<K, unknown> | null): Map<K, unknown>; /** * Combine matching entries from maps. * @param xs maps * @param fm map function (vs, k) * @param fe end function (dones) [array.some] * @param vd default value * @returns [fm([x₀[k₀], x₁[k₀], ...]), fm([x₀[k₁], x₁[k₁], ...]), ...] */ export declare function zip<K, V, W = V>(xs: Map<K, V>[], fm?: MapFunction<K, V[], V[] | W> | null, fe?: EndFunction | null, vd?: V): Map<K, V[] | W>; /** * Segregate entries by test result. * @param x a map * @param ft test function (v, k, x) * @returns [satisfies, doesnt] */ export declare function partition<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): [Map<K, V>, Map<K, V>]; /** * Segregate entries by similarity. * @param x a map * @param fm map function (v, k, x) * @returns Map \{key ⇒ values\} */ export declare function partitionAs<K, V, W = V>(x: Map<K, V>, fm: MapFunction<K, V, V | W>): Map<V | W, Map<K, V>>; /** * Break map into chunks of given size. * @param x a map * @param n chunk size [1] * @param s chunk step [n] * @returns [x[0..n], x[s..s+n], x[2s..2s+n], ...] */ export declare function chunk<K, V>(x: Map<K, V>, n?: number, s?: number): Map<K, V>[]; /** * Append entries from maps, preferring last. * @param xs maps * @returns x₀ ∪ x₁ ∪ ... | [x₀, x₁, ...] = xs */ export declare function concat<K, V>(...xs: Entries<K, V>[]): Map<K, V>; /** * Append entries from maps, preferring last. * @param x a map (updated) * @param ys other maps * @returns x = x ∪ y₀ ∪ y₁ ∪ ... | [y₀, y₁, ...] = ys */ export declare function concat$<K, V>(x: Map<K, V>, ...ys: Entries<K, V>[]): Map<K, V>; /** * Join entries together into a string. * @param x a map * @param sep separator [,] * @param asc associator [=] * @returns "$\{k₀\}=$\{v₀\},$\{k₁\}=$\{v₁\}..." | [kᵢ, vᵢ] ∈ x */ export declare function join<K, V>(x: Entries<K, V>, sep?: string, asc?: string): string; /** * Check if maps have no common keys. * @param x a map * @param y another map * @returns x ∩ y = Φ? */ export declare function isDisjoint<K, V>(x: Map<K, V>, y: Entries<K, V>): boolean; /** * Obtain keys present in any map. * @param xs maps * @returns [k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∪ x₁, ...; [x₀, x₁, ...] = xs */ export declare function unionKeys<K, V>(...xs: Entries<K, V>[]): Set<K>; /** * Obtain entries present in any map. * @param x a map * @param y another map * @param fc combine function (a, b) * @returns x ∪ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y\} */ export declare function union<K, V>(x: Entries<K, V>, y: Entries<K, V>, fc?: CombineFunction<V> | null): Map<K, V>; /** * Obtain entries present in any map. * @param x a map (updated) * @param y another map * @param fc combine function (a, b) * @returns x = x ∪ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y\} */ export declare function union$<K, V>(x: Map<K, V>, y: Entries<K, V>, fc?: CombineFunction<V> | null): Map<K, V>; /** * Obtain keys present in all maps. * @param xs maps * @returns [k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∩ x₁, ...; [x₀, x₁, ...] = xs */ export declare function intersectionKeys<K, V>(...xs: Map<K, V>[]): Set<K>; /** * Obtain entries present in both maps. * @param x a map * @param y another map * @param fc combine function (a, b) * @returns x ∩ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y\} */ export declare function intersection<K, V>(x: Map<K, V>, y: Entries<K, V>, fc?: CombineFunction<V> | null): Map<K, V>; /** * Obtain entries present in both maps. * @param x a map (updated) * @param y another map * @param fc combine function (a, b) * @returns x = x ∩ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y\} */ export declare function intersection$<K, V>(x: Map<K, V>, y: Map<K, V>, fc?: CombineFunction<V> | null): Map<K, V>; /** * Obtain entries not present in another map. * @param x a map * @param y another map * @returns x - y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y\} */ export declare function difference<K, V>(x: Entries<K, V>, y: Entries<K, V>): Map<K, V>; /** * Obtain entries not present in another map. * @param x a map (updated) * @param y another map * @returns x = x - y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y\} */ export declare function difference$<K, V>(x: Map<K, V>, y: Entries<K, V>): Map<K, V>; /** * Obtain entries not present in both maps. * @param x a map * @param y another map * @returns x-y ∪ y-x */ export declare function symmetricDifference<K, V>(x: Entries<K, V>, y: Entries<K, V>): Map<K, V>; /** * Obtain entries not present in both maps. * @param x a map (updated) * @param y another map * @returns x = x-y ∪ y-x */ export declare function symmetricDifference$<K, V>(x: Map<K, V>, y: Entries<K, V>): Map<K, V>; /** * List cartesian product of maps. * @param xs maps * @param fm map function (vs, i) * @returns x₀ × x₁ × ... = \{\{[k₀, v₀], [k₁, v₁], ...\} | [k₀, v₀] ∈ x₀, [k₁, v₁] ∈ x₁, ...]\} */ export declare function cartesianProduct<K, V, W = Map<K, V>>(xs: Map<K, V>[], fm?: MapFunction<number, Map<K, V>, Map<K, V> | W> | null): IterableIterator<Map<K, V> | W>;