product-iterable
v3.0.1
Published
Make a Cartesian product of iterables, or create a Cartesian power of an iterable
Downloads
73
Maintainers
Readme
product-iterable
Requirements
- Node >= 6.0.0
Features
Make a Cartesian product of iterables
Create a Cartesian power of an iterable
Usage
Import
var ProductIterable = require('product-iterable');
Constructor
Cartesian product of iterables
Form
var product = new ProductIterable(...iterables);
Where:
...iterables
are finite iterable objectsproduct
is an iterable of tuples
Example
var product = new ProductIterable('abc', [0, 1, 2, 3]);
console.log(new Set(product));
You would seen a set of (character, number)
pairs
Function: ::pow
a.k.a ::times
Cartesian power of an iterable
Form
var power = ProductIterable.pow(iterable, exponent);
Where:
iterable
is a finite iterable object, let's suppose its length equal to Lexponent
is an unsigned integer, let's call it Epower
is an iterable object which iterates LE number of arrays ofiterable
's elements
Example
var power = ProductIterable.pow('abcd', 3);
console.log(new Set(power));
Just like new ProductIterable('abcd', 'abcd', 'abcd')
, you would seen a set of 43 arrays