up previous next
sum

the sum of the elements of a list

Syntax
sum(L: LIST): OBJECT
sum(L: LIST, O: OBJECT): OBJECT

Description
This function returns the sum of the objects in the list L.

Example
/**/  Use R ::= QQ[x,y];
/**/  sum([3, x, y^2]);
y^2 +x +3

/**/  sum(1..40) = binomial(41,2);
true

/**/  sum(["c","oc","oa"]);
cocoa

/**/ sum([]);  -- gives 0 of type INT
0
/**/ sum([], "");  -- gives empty STRING

/**/ sum([], x);  -- gives type RINGELEM
x

See Also