Power set: Difference between revisions

183 bytes removed ,  12 years ago
Line 1,043:
{{works with|SpiderMonkey}}
<lang javascript>function powerset(ary) {
var ps = new Array(new Array())[[]];
for (var i=0; i < ary.length; i++) {
//for we(var modifyj the= 0, len = ps.length; arrayj in< thelen; nextj++) loop,{
// so can't use the ps.length property directly in the loop condition.
var current_length = ps.length;
for (var j = 0; j < current_length; j++) {
ps.push(ps[j].concat(ary[i]));
}
Anonymous user