SUM

The function SUM takes a List of Numbers or a List of Currencies and adds them all together.

This function takes a List of Numbers or [Currencies] as input. It outputs a single Number: the sum up every number or currency object in the List, added together.

Declaration

SUM(list_of_numbers) -> sum_of_numbers
SUM(list_of_currencies) -> sum_of_currencies

Parameters

list_of_numbers (type: List) A list of Numbers to add together.

list_of_currencies (type: List) A list of Currency objects to add together.

Return Values

sum_of_numbers (type: Number) Number representing the sum of all the Numbers in the given List.

sum_of_currencies (type: Number) Number representing the sum of all the Currencies in the given List.

Examples

The first example takes a List of Numbers and returns the sum of all the Numbers in the given List.

The second example takes a List of Currencies and returns a sum of all Currency objects in the given List.

SUM([1, 4, 3, 3, 2]) -> 13
SUM([
  {
    "amount": 250,
    "code": "USD",
    "precision": 2
  },
  {
    "amount": 100,
    "code": "USD",
    "precision": 2
  }
]) ->{
  "amount": 350,
  "code": "USD",
  "precision": 2
}

Last updated