You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package util
|
|
|
|
import (
|
|
"golang.org/x/exp/constraints"
|
|
)
|
|
|
|
type Numeric interface {
|
|
constraints.Float | constraints.Integer
|
|
}
|
|
|
|
func Abs[T Numeric](a T) T {
|
|
if a < 0 {
|
|
return -a
|
|
}
|
|
|
|
return a
|
|
}
|