Home / Docs / Standard library / Prelude
min
Release v0.4.0Edition 0.1 and later
A function of the prelude, in scope in every module. Edition 0.1 and later.
Edition 0.1
una
pub min(a: Int, b: Int) -> Int
ensures result <= a and result <= b and (result == a or result == b)The smaller of a and b; in edition 0.2 and later, of any type with Ord (spec/14 §1, spec/20 §6).
Edition 0.2 and later
una
pub min[T: Ord](a: T, b: T) -> T
ensures result <= a and result <= b and (result == a or result == b)The smaller of a and b; in edition 0.2 and later, of any type with Ord (spec/14 §1, spec/20 §6).
In editions 0.2, 0.3, 0.4, 0.5. In edition 0.1: min(a: Int, b: Int) -> Int: integers only.
Parameters
a: a valueb: another value of the same type
Returns
T: the smaller of a and b: result <= a, result <= b, and it is one of them.
See also
Example
src/shop.una
module shop
--- The price to charge, the lower of the list price and the sale price, and the first of two
--- names in the order of their scalar values.
pub main() -> Unit
uses @console: Console[print]
=
let price = min(1999, b: 1499)
@console.print("{price} cents")
let first = min("Desk lamp", b: "Chair")
@console.print(first)una run . prints:
Output
1499 cents
ChairSpecification
Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.