1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-04-07 10:30:12 +08:00
parent a872181c66
commit cfa90dff4f

View File

@ -1,19 +1,16 @@
package mathx
// MaxInt returns the larger one of a and b.
func MaxInt(a, b int) int {
if a > b {
return a
}
import (
"github.com/charlienet/go-mixed/expr"
"golang.org/x/exp/constraints"
)
return b
// MaxInt returns the larger one of v1 and v2.
func Max[T constraints.Ordered](v1, v2 T) T {
return expr.If(v1 > v2, v1, v2)
}
// MinInt returns the smaller one of a and b.
func MinInt(a, b int) int {
if a < b {
return a
}
return b
// MinInt returns the smaller one of v1 and v2.
func Min[T constraints.Ordered](v1, v2 T) T {
return expr.If(v1 < v2, v1, v2)
}