Calculates Cartesian product of provided sets.
Parameters:
| Name | Type | Description |
|---|---|---|
sets |
Array | Array of sets. |
- Source:
Returns:
Cartesian product of provided sets.
- Type
- Array
Example
var product = require('path-to-algorithms/src/combinatorics/' +
'cartesianproduct').cartesianProduct;
var result = product([[1, 2, 3], [3, 2, 1]]);
// [ [ 1, 3 ],
// [ 1, 2 ],
// [ 1, 1 ],
// [ 2, 3 ],
// [ 2, 2 ],
// [ 2, 1 ],
// [ 3, 3 ],
// [ 3, 2 ],
// [ 3, 1 ] ]
console.log(result);