pivots #1

Merged
SethTrowbridge merged 17 commits from pivots into master 2021-05-15 12:05:52 -04:00
Showing only changes of commit a127d702a3 - Show all commits

View File

@ -71,6 +71,40 @@ var N = {
} }
}; };
</script> </script>
<script>
var rows = [
["a", 1],
["b", 2],
["a", 3],
["b", 1],
["a", 0],
["b", 7],
];
Uniques = (inRows, inColumnIndex, inSumIndicies) =>
{
let uniques = {};
inRows.forEach((inRow)=>
{
let value = inRow[inColumnIndex];
let match = uniques[value];
if(!match)
{
match = uniques[value] = {Sum:[...inRow], Rows:[]};
}
else
{
inSumIndicies.forEach(inIndex => match.Sum[inIndex] += inRow[inIndex]);
}
match.Rows.push(inRow);
});
return uniques;
};
console.log(Uniques(rows, 0, [1]));
</script>
<script> <script>
let tree1 = N.Create("root1", let tree1 = N.Create("root1",
N.Create("branch1", N.Create("branch1",