Add Num.min and Num.max

Implements #5533
This commit is contained in:
Fábio Beirão 2023-06-09 14:16:28 +02:00
parent 2faa0e4c5b
commit ec94fc87a5
No known key found for this signature in database
GPG key ID: 13FD3A2130278AAE
3 changed files with 56 additions and 0 deletions

View file

@ -39,6 +39,8 @@ interface Num
add,
sub,
mul,
min,
max,
isLt,
isLte,
isGt,
@ -777,6 +779,34 @@ sub : Num a, Num a -> Num a
## ∞ or -∞. For all other number types, overflow results in a panic.
mul : Num a, Num a -> Num a
## Obtains the smaller between two numbers of the same type.
##
## ```
## Num.min 100 0
##
## Num.min 3.0 -3.0
## ```
min : Num a, Num a -> Num a
min = \a, b ->
if a < b then
a
else
b
## Obtains the greater between two numbers of the same type.
##
## ```
## Num.max 100 0
##
## Num.max 3.0 -3.0
## ```
max : Num a, Num a -> Num a
max = \a, b ->
if a > b then
a
else
b
sin : Frac a -> Frac a
cos : Frac a -> Frac a