power set | JavaScript

December 24th, 2021 07:57:44 PM

					
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => r.concat(v))), [[]]); powerset([1, 2]); // [[], [1], [2], [1, 2]]

Featured Posts