From 231bb696342c814a2d2b3cb00b24aed77b8c7009 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Thu, 9 Jan 2020 14:28:54 -0800 Subject: [PATCH] Fixed bug introduced into sum() when summing lists of vectors. --- math.scad | 7 ++----- version.scad | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/math.scad b/math.scad index 4678d1f..ab977a6 100644 --- a/math.scad +++ b/math.scad @@ -429,12 +429,9 @@ function lcm(a,b=[]) = // Example: // sum([1,2,3]); // returns 6. // sum([[1,2,3], [3,4,5], [5,6,7]]); // returns [9, 12, 15] -function sum(v, _i=0, _acc=undef) = +function sum(v, _i=0, _acc) = _i>=len(v)? _acc : - sum( - v, _i=_i+1, - _acc=v[_i] + (is_undef(_acc)? 0 : _acc) - ); + sum(v, _i=_i+1, _acc=is_undef(_acc)? v[_i] : _acc+v[_i]); // Function: cumsum() diff --git a/version.scad b/version.scad index 62186d2..2260695 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,75]; +BOSL_VERSION = [2,0,76]; // Section: BOSL Library Version Functions