2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
19
Task/Power-set/JavaScript/power-set-4.js
Normal file
19
Task/Power-set/JavaScript/power-set-4.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
|
||||
// powerset :: [a] -> [[a]]
|
||||
const powerset = xs =>
|
||||
xs.reduceRight((a, x) => a.concat(a.map(y => [x].concat(y))), [
|
||||
[]
|
||||
]);
|
||||
|
||||
|
||||
// TEST
|
||||
return {
|
||||
'[1,2,3] ->': powerset([1, 2, 3]),
|
||||
'empty set ->': powerset([]),
|
||||
'set which contains only the empty set ->': powerset([
|
||||
[]
|
||||
])
|
||||
};
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue