diff --git a/src/util/sum.scad b/src/util/sum.scad index 1bc28a97..4d66c5ec 100644 --- a/src/util/sum.scad +++ b/src/util/sum.scad @@ -9,5 +9,8 @@ **/ function sum(lt) = - let(leng = len(lt)) - [for(i = 0; i < leng; i = i + 1) 1] * lt; \ No newline at end of file + let( + end = len(lt) - 1, + cum_total = [for(i = 0, s = lt[0]; i < end; i = i + 1, s = s + lt[i]) s] + ) + cum_total[len(cum_total) - 1] + lt[end]; \ No newline at end of file