2022-04-02 13:01:41 +02:00
|
|
|
package views
|
|
|
|
|
|
|
|
func min(x, y int) int {
|
|
|
|
if x < y {
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
return y
|
|
|
|
}
|
|
|
|
|
|
|
|
func max(x, y int) int {
|
|
|
|
if x > y {
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
return y
|
|
|
|
}
|
|
|
|
|
2022-04-03 16:29:01 +02:00
|
|
|
func limit(v, minv, maxv int) int {
|
|
|
|
return min(max(v, minv), maxv)
|
|
|
|
}
|
|
|
|
|
2022-04-02 13:01:41 +02:00
|
|
|
func iff[T any](condition bool, trueValue, falseValue T) T {
|
|
|
|
if condition {
|
|
|
|
return trueValue
|
|
|
|
}
|
|
|
|
return falseValue
|
|
|
|
}
|