combinations
![npm download](https://img.shields.io/npm/dm/ml-combinations.svg?style=flat-square)
Generate all possible unordered samples of size m, without replacement, from a set of n objects
Very low memory footprint even if the number of combinations to generate is high.
Installation
$ npm install ml-combinations
Usage
const combinations = require('ml-combinations');
const options = {mode: 'index'};
var gen = combinations(2, 4, options);
for(let combination of gen) {
console.log(combination);
}
console.log([...gen]);
options.mode = 'mask';
gen = combinations(2, 4, options);
console.log([...gen]);
References
Phillip J Chase, `Algorithm 382: Combinations of M out of N Objects [G6]',
Communications of the Association for Computing Machinery 13:6:368 (1970).
To the article
License
MIT