Aggregate numbers

The aggregate-numbers function calculates statistical aggregations of a set of numbers. It takes one required parameter: a list of numbers to be aggregated. It also accepts one optional parameter, type, which specifies the type of aggregation to be performed.

Syntax

aggregate-numbers(numbers, type='sum')

Parameters

  • numbers: A list of numbers to be aggregated.
  • type: The type of aggregation to be performed. This can be one of the following values:
    • sum: The sum of the numbers in the list. This is the default value.
    • average: The average (arithmetic mean) of the numbers in the list.
    • median: The median of the numbers in the list.

Return value

The aggregate-numbers function returns a single number, which is the result of the specified aggregation.

Examples

Here are a few examples of how to use the aggregate-numbers function:

= aggregate-numbers([1, 2, 3, 4, 5], type="sum")  # Returns 15 (sum of the numbers)
= aggregate-numbers([1, 2, 3, 4, 5], type='average')  # Returns 3 (average of the numbers)
= aggregate-numbers([1, 2, 3, 4, 5], type='median')  # Returns 3 (median of the numbers)