update snippets 78 - 96
This commit is contained in:
@ -7,5 +7,8 @@ Use `Array.reduce()` combined with `Array.map()` to iterate over elements and co
|
||||
```js
|
||||
const powerset = arr =>
|
||||
arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
||||
// powerset([1,2]) -> [[], [1], [2], [2,1]]
|
||||
```
|
||||
|
||||
```js
|
||||
powerset([1,2]) -> [[], [1], [2], [2,1]]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user