Synopsis:
sum(n,f) -- compute the sum f(0) + f(1) + ... + f(n-1).
i1 : sum(10, i -> i^2) |
See also:
Code:
-- ../../../Macaulay2/m2/lists.m2:59-65 sum(ZZ,Function) := (n,f) -> ( s := 0; g := x -> ( s = f x; g = x -> s = s + f x); scan(n,x -> g x); s);