411 REFERENCE · Wikibooks
OpenSCAD User Manual/Suggest Reduce Function
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Implement a reduce() Function
Not that i know how to do this .. but i did find a good explanation of what would be needed and started this page
Issues to do with reduce in a functional language
I believe it has been done here: https://github.com/andy128k/scad_utils/blob/2c6b2fa847380a17bfbced4d7235f884330cd06a/lists.scad#L76
// Fold
function list_fold(list, func, acc = undef, index = 0) =
index >= len(list)
? acc
: list_fold(list, func, func(acc, list[index]), index + 1);
For example, echo(list_fold([1,2,3], function(a, b) a + b, 0)); will echo 6.