mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
16 lines
326 B
Go
16 lines
326 B
Go
package underscore
|
|
|
|
import "constraints"
|
|
|
|
// Min returns the minimum value in the slice.
|
|
// This function can currently only compare numbers reliably.
|
|
// This function uses operator <.
|
|
func Min[T constraints.Ordered](values []T) T {
|
|
min := values[0]
|
|
for _, v := range values {
|
|
if v < min {
|
|
min = v
|
|
}
|
|
}
|
|
return min
|
|
}
|