Home / Docs / Standard library / Prelude
max
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 max(a: Int, b: Int) -> Int
ensures result >= a and result >= b and (result == a or result == b)The larger 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 max[T: Ord](a: T, b: T) -> T
ensures result >= a and result >= b and (result == a or result == b)The larger 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: max(a: Int, b: Int) -> Int: integers only.
Parameters
a: a valueb: another value of the same type
Returns
T: the larger of a and b: result >= a, result >= b, and it is one of them.
See also
Example
src/shop.una
module shop
--- How many units to reorder, never fewer than none, and the last of two names in the order of
--- their scalar values.
pub main() -> Unit
uses @console: Console[print]
=
let reorder = max(0, b: 10 - 14)
@console.print("reorder {reorder}")
let last = max("Desk lamp", b: "Chair")
@console.print(last)una run . prints:
Output
reorder 0
Desk lampSpecification
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.