September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,23 @@
(() => {
'use strict';
// disjointSort :: [a] -> [Int] -> [a]
const disjointSort = (xs, indices) => {
// Sequence of indices discarded
const indicesSorted = indices.sort(),
subsetSorted = indicesSorted
.map(i => xs[i])
.sort();
return xs
.map((x, i) => {
const iIndex = indicesSorted.indexOf(i);
return iIndex !== -1 ? (
subsetSorted[iIndex]
) : x;
});
};
return disjointSort([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7]);
})();