CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
power-set.js28 linesDownload Raw Back to obliterator
1/**2 * Obliterator Power Set Function3 * ===============================4 *5 * Iterator returning the power set of the given array.6 */7var Iterator = require('./iterator.js'),8  combinations = require('./combinations.js'),9  chain = require('./chain.js');10 11/**12 * Power set.13 *14 * @param  {array}    array - Target array.15 * @return {Iterator}16 */17module.exports = function powerSet(array) {18  var n = array.length;19 20  var iterators = new Array(n + 1);21 22  iterators[0] = Iterator.of([]);23 24  for (var i = 1; i < n + 1; i++) iterators[i] = combinations(array, i);25 26  return chain.apply(null, iterators);27};28 
basant307/AI_Governance_Project · CoolFace