Maximum macro
Learn how to find the largest number in a collection.
This macro returns the maximum value in a collection.
The maximum is the largest of all the numbers in the collection. For example, the maximum of the numbers 2, 3, 4, 7, and 9 is 9.
Since an empty collection has no maximum, trying to get the maximum of an empty collection results in an error. So be sure to provide a default value in cases where the collection might be empty.
Syntax
This macro has the following syntax:
maximum of /*<collection>*/
Alternatively, you can use the abbreviated form:
max of /*<collection>*/
You can also prefix the macro with a definite article for readability:
the maximum of /*<collection>*/
Parameters
These are the supported parameters:
- collection
A non-empty collection of numbers from which you want to find the maximum. Elements are automatically converted to numbers if necessary.
Examples
Here is an example of how to get the maximum value of a collection of numbers:
maximum of [1.5, 2.5, "3"] // 3
In cases where the collection might be empty, you can provide a default value:
maximum of /*<collection>*/ or else null