27 lines
373 B
Go
27 lines
373 B
Go
|
package views
|
||
|
|
||
|
func min[T int | float64](x, y T) T {
|
||
|
if x < y {
|
||
|
return x
|
||
|
}
|
||
|
return y
|
||
|
}
|
||
|
|
||
|
func max[T int | float64](x, y T) T {
|
||
|
if x > y {
|
||
|
return x
|
||
|
}
|
||
|
return y
|
||
|
}
|
||
|
|
||
|
func limit[T int | float64](v, minv, maxv T) T {
|
||
|
return min(max(v, minv), maxv)
|
||
|
}
|
||
|
|
||
|
func iff[T any](condition bool, trueValue, falseValue T) T {
|
||
|
if condition {
|
||
|
return trueValue
|
||
|
}
|
||
|
return falseValue
|
||
|
}
|