Fixed bug introduced into sum() when summing lists of vectors.

This commit is contained in:
Revar Desmera 2020-01-09 14:28:54 -08:00
parent 48d30fc686
commit 231bb69634
2 changed files with 3 additions and 6 deletions

View file

@ -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()

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,75];
BOSL_VERSION = [2,0,76];
// Section: BOSL Library Version Functions