Calculates the Power Set of a set S.
This method calculates the Power Set of value
. Array sparseness is
ignored.
In mathematics, the power set (or powerset) of any set S, written P(S), ℘(S), P(S), ℙ(S) or 2S, is the set of all subsets of S, including the empty set and S itself.
Kind: Exported function
Returns: Array.<Array>
- The power set of value
.
See: http://en.wikipedia.org/wiki/Power_set
Param | Type | Description |
---|---|---|
value | Array |
The array like value to get the power set of. |
Example
import powerSet from 'power-set-x';
console.log(powerSet([1, 2, 3])); // [[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]