1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-24 23:31:50 +02:00
Files
BezierInfo-2/test.js
2020-10-18 14:27:57 -07:00

22 lines
420 B
JavaScript

const lookup = {};
const arrays = [
[0, 1, 2, 3, 4, 4, 4, 4],
[5, 6, 7, 8, 9, 10, 11, 11],
[2, 7, 10, 12],
[0, 7, 10, 14]
];
const reduced = arrays.map((array, index) => {
for(let i=array.length-1; i>=0; i--) {
let value = array[i];
let knownIndex = (lookup[value] = lookup[value] ?? index);
if (knownIndex < index) {
array.splice(i,1);
}
}
return array;
});
console.log(reduced);