core3-utils

@wixc3/common on Github

Home > @wixc3/common > getCartesianProduct

getCartesianProduct() function

Signature:

export declare function getCartesianProduct<T>(arrays: T[][]): T[][];

Parameters

Parameter Type Description
arrays T\[\]\[\]

Returns:

T[][]

an array containing all the combinations of one element from each array

Example

getCartesianProduct([
                [1, 2],
                [3, 4],
            ]); // => [[1, 3], [1, 4], [2, 3], [2, 4]]