Lists cartesian product of arrays.
npm install @extra-array/cartesian-product.minLists cartesian product of arrays.
:package:
:smiley_cat:
:running:
:vhs:
:moon:
:scroll:
:newspaper:
:blue_book:
> Similar: [cartesianProduct], [zip].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
> This is browserified, minified version of [@extra-array/cartesian-product].
> It is exported as global variable array_cartesianProduct.
> CDN: [unpkg], [jsDelivr].
[@extra-array/cartesian-product]: https://www.npmjs.com/package/@extra-array/cartesian-product
[unpkg]: https://unpkg.com/@extra-array/cartesian-product.min
[jsDelivr]: https://cdn.jsdelivr.net/npm/@extra-array/cartesian-product.min
``javascript`
array.cartesianProduct(xs, [fm]);
// xs: arrays
// fm: map function (vs, i)
`javascript
const array = require("extra-array");
var x = [1, 2, 3];
var y = [10, 20, 30];
array.cartesianProduct([x, y]);
// [
// [ 1, 10 ], [ 1, 20 ],
// [ 1, 30 ], [ 2, 10 ],
// [ 2, 20 ], [ 2, 30 ],
// [ 3, 10 ], [ 3, 20 ],
// [ 3, 30 ]
// ]
array.cartesianProduct([x, y], ([a, b]) => a + b);
// [
// 11, 21, 31, 12, 22,
// 32, 13, 23, 33
// ]
``
- Data.Set.cartesianProduct: Haskell
- List-Extra.cartesianProduct: elm
- itertools.product: Python
- Guava.Lists: Java
- fast-cartesian-product: @fisker
- cartesian-product: @izaakschroeder
- cartesian: @alexindigo
[cartesianProduct]: https://github.com/nodef/extra-array/wiki/cartesianProduct
[zip]: https://github.com/nodef/extra-array/wiki/zip