sum

returns the sum of a list of numbers.

# Metadata

Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

sum(numbersList)

# Params

- numbersList : * a sequence of parameters, each a number or evaluating to a number or * a single parameter which is or evaluates to * a comma-separated list of numbers or * an array containing only numbers

# Examples

put sum(1,5,2,3) -- returns 11

# Description

Use the sum function to add a group of values together.

The sum function is equivalent to the following statements:

repeat with x = 1 to the number of items of numbersList add item x of numbersList to sumValue end repeat return sumValue

If the numbersList is empty, the sum function returns zero.

If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information.

# Tags

# See

- **operator:** [[+]] - **command:** add, group - **function:** standardDeviation, min, max, extents - **control structure:** function - **glossary:** statement, return, value, math operation