sum

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
sum(<numbersList>)
Summary

Returns the sum of a list of numbers.

Introduced1.0
Changes

The ability to use an array was introduced in version 1.1. In previous versions, only lists of numbers could be used with the sum function.

OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
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
Example
put sum(1,5,2,3) -- returns 11
Values
NameTypeDescription
return

The sum function returns a number.

RelatedOperator: +
Command: add, group
Function: standardDeviation, min, max, extents
Control Structure: function
Glossary: statement, return, value, math operation
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.