@extra-iterable/cartesian-product.min

Lists cartesian product of iterables.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/cartesian-product.min
102.5.222 years ago2 years agoMinified + gzip package size for @extra-iterable/cartesian-product.min in KB

Readme

Lists cartesian product of iterables. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Similar: cartesianProduct, zip.

This is part of package extra-iterable.

This is browserified, minified version of @extra-iterable/cartesian-product.
It is exported as global variable iterablecartesianProduct.
CDN: unpkg
, jsDelivr.



iterable.cartesianProduct(xs, [fm]);
// xs: iterables
// fm: map function (vs, i)

const iterable = require("extra-iterable");

var x = [1, 2, 3];
var y = [10, 20, 30];
[...iterable.cartesianProduct([x, y])];
// [
//   [ 1, 10 ], [ 1, 20 ],
//   [ 1, 30 ], [ 2, 10 ],
//   [ 2, 20 ], [ 2, 30 ],
//   [ 3, 10 ], [ 3, 20 ],
//   [ 3, 30 ]
// ]

[...iterable.cartesianProduct([x, y], ([a, b]) => a + b)];
// [
//   11, 21, 31, 12, 22,
//   32, 13, 23, 33
// ]



References