Added samples
This commit is contained in:
@ -5,4 +5,5 @@ Use `reduce()` combined with `map()` to iterate over elements and combine into a
|
||||
```js
|
||||
const powerset = arr =>
|
||||
arr.reduce( (a,v) => a.concat(a.map( r => [v].concat(r) )), [[]]);
|
||||
// powerset([1,2]) -> [[], [1], [2], [2,1]]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user