I don't know if it's important to you, but your Max[float64] isn't compatible with math.Max in the standard library. For example, Max[float64](NaN, 1) returns 1 rather than NaN.
On Tuesday, 22 March 2022 at 16:58:40 UTC+1 esi...@gmail.com wrote: > I found a working version meantime. > > // Max returns the bigger value between two numbers. > func Max[T constraints.Ordered](x, y T) T { > if x > y { > return x > } > return y > } > > // Abs returns the absolut value of x. > func Abs[T constraints.Signed | constraints.Float](x T) T { > if x < 0 { > return -x > } > return x > } > > On Saturday, March 19, 2022 at 12:22:39 PM UTC+2 Gergely Födémesi wrote: > >> some details: https://github.com/golang/go/issues/48918 >> >> On 3/18/22, Endre Simo <esi...@gmail.com> wrote: >> > Now that generics are officially supported, I was checking in the Go >> source >> > >> > if there are some generic implementation of utility methods like Abs, >> Min, >> > Max etc, but I couldn't find it other than this >> > proposal https://github.com/golang/go/discussions/48287. >> > >> > Anyone knows if something related has been adopted and implemented in >> Go >> > 1.18? >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to golang-nuts...@googlegroups.com. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/golang-nuts/e930b89a-0ba6-46f5-b3ec-7aeb26d8acf9n%40googlegroups.com. >> >> >> > >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5a96dccf-2e52-4172-bd2f-e1bf0e8757b4n%40googlegroups.com.