cartesianProduct
Perform a Cartesian product of arrays
164 bytes
Usage
Create an n-ary Cartesian product from the given arrays. The inputs are arrays, and the output is an array of arrays representing all possible combinations where the first element is from the first array, the second element is from the second array, and so on.
import * as import _
_ from 'radashi'
const const colors: string[]
colors = ['red', 'blue']const const numbers: number[]
numbers = [1, 2, 3]const const booleans: boolean[]
booleans = [true, false]
import _
_.cartesianProduct<[string[], number[], boolean[]]>(arrays_0: string[], arrays_1: number[], arrays_2: boolean[]): [string, number, boolean][]export cartesianProduct
Create an n-ary Cartesian product
from the given arrays.
cartesianProduct(const colors: string[]
colors, const numbers: number[]
numbers, const booleans: boolean[]
booleans)// => [// ['red', 1, true],// ['red', 1, false],// ['red', 2, true],// ['red', 2, false],// ['red', 3, true],// ['red', 3, false],// ['blue', 1, true],// ['blue', 1, false],// ['blue', 2, true],// ['blue', 2, false],// ['blue', 3, true],// ['blue', 3, false],// ]