From db7047c394edbcc713accda2a15f201a5b400ef7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 13 Jul 2022 20:16:46 -0600 Subject: Misc tidy up --- lib/slices/sliceutil.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'lib/slices') diff --git a/lib/slices/sliceutil.go b/lib/slices/sliceutil.go index 392514f..faaffcb 100644 --- a/lib/slices/sliceutil.go +++ b/lib/slices/sliceutil.go @@ -48,18 +48,24 @@ func Reverse[T any](slice []T) { } } -func Max[T constraints.Ordered](a, b T) T { - if a > b { - return a +func Max[T constraints.Ordered](a T, rest ...T) T { + ret := a + for _, b := range rest { + if b > a { + ret = b + } } - return b + return ret } -func Min[T constraints.Ordered](a, b T) T { - if a < b { - return a +func Min[T constraints.Ordered](a T, rest ...T) T { + ret := a + for _, b := range rest { + if b < a { + ret = b + } } - return b + return ret } func Sort[T constraints.Ordered](slice []T) { -- cgit v1.2.3-2-g168b