//#region src/array/cartesianProduct.d.ts /** * Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays. * * @template T * @param {readonly T[]} arr1 - The array to take the product of. * @returns {Array<[T]>} An array of single-element tuples. */ declare function cartesianProduct(arr1: readonly T[]): Array<[T]>; /** * Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays. * * @template T, U * @param {readonly T[]} arr1 - The first array to take the product of. * @param {readonly U[]} arr2 - The second array to take the product of. * @returns {Array<[T, U]>} An array of tuples representing the Cartesian product. * * @example * cartesianProduct([1, 2], ['a', 'b']); * // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] */ declare function cartesianProduct(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>; /** * Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays. * * @template T, U, V * @param {readonly T[]} arr1 - The first array to take the product of. * @param {readonly U[]} arr2 - The second array to take the product of. * @param {readonly V[]} arr3 - The third array to take the product of. * @returns {Array<[T, U, V]>} An array of tuples representing the Cartesian product. */ declare function cartesianProduct(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>; /** * Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays. * * @template T, U, V, W * @param {readonly T[]} arr1 - The first array to take the product of. * @param {readonly U[]} arr2 - The second array to take the product of. * @param {readonly V[]} arr3 - The third array to take the product of. * @param {readonly W[]} arr4 - The fourth array to take the product of. * @returns {Array<[T, U, V, W]>} An array of tuples representing the Cartesian product. */ declare function cartesianProduct(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>; /** * Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays. * * Returns every possible tuple formed by picking one element from each input array, in lexicographic order. * The rightmost array advances fastest, like the digits of an odometer. * * If no arrays are passed, the result is `[[]]` (a single empty tuple). * If any input array is empty, the result is `[]`. * * @template T * @param {Array} arrs - The arrays to take the product of. * @returns {T[][]} An array of tuples representing the Cartesian product. * * @example * cartesianProduct([1, 2], ['a', 'b']); * // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] * * @example * cartesianProduct([0, 1], [0, 1], [0, 1]); * // => [[0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]] * * @example * cartesianProduct([1, 2, 3], []); * // => [] * * @example * cartesianProduct(); * // => [[]] */ declare function cartesianProduct(...arrs: Array): T[][]; //#endregion export { cartesianProduct };