min, max and limit implemented
This commit is contained in:
commit
ff2f846cea
19
limits.go
Normal file
19
limits.go
Normal file
@ -0,0 +1,19 @@
|
||||
package gmath
|
||||
|
||||
func Min[N Number](a, b N) N {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func Max[N Number](a, b N) N {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func Limit[N Number](v, min, max N) N {
|
||||
return Min(Max(v, min), max)
|
||||
}
|
Loading…
Reference in New Issue
Block a user