Minimum macro

Learn how to find the smallest number in a collection.

This macro returns the minimum value in a collection.

The minimum is the smallest of all the numbers in the collection. For example, the minimum of the numbers 2, 3, 4, 7, and 9 is 2.

Since an empty collection has no minimum, trying to get the minimum 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:

minimum of /*<collection>*/
Try in Playground

Alternatively, you can use the abbreviated form:

min of /*<collection>*/
Try in Playground

You can also prefix the macro with a definite article for readability:

the minimum of /*<collection>*/
Try in Playground

Parameters

These are the supported parameters:

collection

A non-empty collection of numbers from which you want to find the minimum. Elements are automatically converted to numbers if necessary.

Examples

Here is an example of how to get the minimum value of a collection of numbers:

minimum of [1.5, 2.5, "3"] // 1.5
Try in Playground

In cases where the collection might be empty, you can provide a default value:

minimum of /*<collection>*/ or else null
Try in Playground