summaryrefslogtreecommitdiff
path: root/common/minmax.go
blob: b670887ca1a60baab220afa99465d4d44ca3245d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package common

/*
Golang is a piece of shit. Its creators are paranoids.
*/

import (
	"golang.org/x/exp/constraints"
)

type Number interface {
	constraints.Integer | constraints.Float
}

func Min[T Number](t1 T, t2 T) T {
	if t1 < t2 {
		return t1
	}
	return t2
}

func Max[T Number](t1 T, t2 T) T {
	if t1 > t2 {
		return t1
	}
	return t2
}