Skip to content

Instantly share code, notes, and snippets.

@jyemin
Created September 22, 2022 20:06
Show Gist options
  • Save jyemin/09433eaa638d532f17e64a0b5f399318 to your computer and use it in GitHub Desktop.
Save jyemin/09433eaa638d532f17e64a0b5f399318 to your computer and use it in GitHub Desktop.
An "annotated" aggregation expression showing intermediate values at everly level of the expression tree
{
"$reduce": { // 300
"input": { // [2, 4, 6, 8, 10]
"$map": { // [2, 4, 6, 8, 10]
"input": { // [2, 4, 6, 8, 10]
"$filter": { // [2, 4, 6, 8, 10]
"input": "$numList", // [1, 2, 3, 4, 5, 6, 7, 8, 9. 10]
"cond": {
"$eq": [ // [false, true, false, true, false, true, false, true, false, true]
{
"$mod": [ // [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
"$$this",
2 // 2
]
},
0 // 0
]
}
}
},
"in": { // [20, 40, 60, 80, 100]
"$multiply": [ // [20, 40, 60, 80, 100]
"$$this",
10
]
}
}
},
"initialValue": 0, // 0
"in": { // 300
"$add": [ // [0, 20, 60, 120, 200, 300]
"$$value",
"$$this"
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment