Skip to main content
Log in

Mojo function

min

min(x: Int, y: Int, /) -> Int

Gets the minimum of two integers.

Args:

  • x (Int): Integer input to min.
  • y (Int): Integer input to min.

Returns:

Minimum of x and y.

min(x: UInt, y: UInt, /) -> UInt

Gets the minimum of two integers.

Args:

  • x (UInt): Integer input to min.
  • y (UInt): Integer input to min.

Returns:

Minimum of x and y.

min[dtype: DType, //](x: SIMD[dtype, size], y: SIMD[dtype, size], /) -> SIMD[dtype, size]

Gets the elementwise minimum of x and y.

An element of the result SIMD vector will be the minimum of the corresponding elements in x and y.

Constraints:

The type of the inputs must be numeric or boolean.

Parameters:

  • dtype (DType): The data type of the SIMD vector.

Args:

  • x (SIMD[dtype, size]): First SIMD vector.
  • y (SIMD[dtype, size]): Second SIMD vector.

Returns:

A SIMD vector containing the elementwise minimum of x and y.

min[T: _CopyableLessThanComparable](x: T, *ys: T) -> T

Gets the minimum value from a sequence of values.

Parameters:

  • T (_CopyableLessThanComparable): A type that is both copyable and comparable with less than.

Args:

  • x (T): The first value to compare.
  • *ys (T): Zero or more additional values to compare.

Returns:

The minimum value from the input sequence.