Result is sum(Vector)which should be preferred.
A vector is a list, an array, or a collection expression (as accepted by eval_to_list/2), whose elements are numbers.
If Vector is a single vector, then Result is the sum of its elements.
If Vector is of the form V1*V2, where V1 and V2 are vectors, then Result is the sum of the pair-wise products of the vector elements (scalar product). If V1 and V2 are of different size, the missing elements are considered to be zero.
If the vector elements are of different number types, then contagion rules apply, i.e. the result is of the widest type that occurs among the vector elements (integer -> rational -> float -> breal).
In coroutining mode, if the list is only partly instantiated, the predicate delays until the list is complete.
Success: X is sum(). % gives X = 0 X is sum([1,2,3]). % gives X = 6 X is sum([1,2.0,3]). % gives X = 6.0 X is sum((1,2,3)). % gives X = 6 A=(4,5,6,7), X is sum(A[2..3]). % gives X = 11 X is sum([1,2,3] * [4,5,6]). % gives X = 32 M = ((1,2,3), (4,5,6), (7,8,9)), X is sum(M[2,*] * M[*,1]). % gives X = 66