- Sort Score
- Result 10 results
- Languages All
Results 1 - 2 of 2 for SliceMin (0.07 sec)
-
test/typeparam/sliceimp.dir/main.go
} func TestMin() { s1 := []int{1, 2, 3, -5} if got, want := a.SliceMin(s1), -5; got != want { panic(fmt.Sprintf("a.Min(%v) = %d, want %d", s1, got, want)) } s2 := []string{"aaa", "a", "aa", "aaaa"} if got, want := a.SliceMin(s2), "a"; got != want { panic(fmt.Sprintf("a.Min(%v) = %q, want %q", s2, got, want)) } if got, want := a.SliceMin(s2[:0]), ""; got != want {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Mar 24 02:14:15 UTC 2022 - 4.6K bytes - Viewed (0) -
test/typeparam/sliceimp.dir/a.go
return zero } return Reduce(s[1:], s[0], Max[Elem]) } // Min returns the minimum element in a slice of some ordered type. // If the slice is empty it returns the zero value of the element type. func SliceMin[Elem Ordered](s []Elem) Elem { if len(s) == 0 { var zero Elem return zero } return Reduce(s[1:], s[0], Min[Elem]) } // Append adds values to the end of a slice, returning a new slice.
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Aug 30 01:55:58 UTC 2021 - 3.3K bytes - Viewed (0)