sum

sum(v,f) -- yields the sum of the expressions obtained by applying f to each of the elements of the list v.

     i1 = sum(1 .. 10, i -> i^2)
     
     o1 = 385
     

sum(v,w,f) -- yields the sum of the expressions obtained by applying f to each of the pairs (i,j) of elements from the lists or sequences v and w, which should be of the same length.

sum(n,f) -- is equivalent to sum(0 .. n-1, f) when n is an integer

sum v -- yields the sum of the elements in the list v.

See also product.

Go to main index.

Go to concepts index.