Documentation
¶
Index ¶
- func Abs[T constraints.Integer | constraints.Float](n T) T
- func Average[T constraints.Integer | constraints.Float](nums ...T) float64
- func Dim[T constraints.Integer | constraints.Float](x, y T) T
- func DivCeil[T constraints.Integer | constraints.Float](x, y T) T
- func DivFloor[T constraints.Integer | constraints.Float](x, y T) T
- func DivRound[T constraints.Integer | constraints.Float](x, y T) T
- func IsEven[T constraints.Integer](n T) bool
- func IsNegative[T constraints.Integer | constraints.Float](n T) bool
- func IsNonNegative[T constraints.Integer | constraints.Float](n T) bool
- func IsNonPositive[T constraints.Integer | constraints.Float](n T) bool
- func IsOdd[T constraints.Integer](n T) bool
- func IsPositive[T constraints.Integer | constraints.Float](n T) bool
- func IsZero[T constraints.Integer | constraints.Float](n T) bool
- func Max[T constraints.Ordered](nums ...T) T
- func MaxBy[T any](slice []T, cmp func(a, b T) bool) T
- func Min[T constraints.Ordered](nums ...T) T
- func MinBy[T any](slice []T, cmp func(a, b T) bool) T
- func Mod[T constraints.Integer | constraints.Float](x, y T) T
- func Pow[T constraints.Integer | constraints.Float](x, y T) T
- func Range[T constraints.Signed | constraints.Float](start, stop T, step ...T) []T
- func Sign[T constraints.Integer | constraints.Float](n T) int
- func Sum[T constraints.Ordered](nums ...T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T constraints.Integer | constraints.Float](n T) T
Abs returns the absolute int value of n.
func Average ¶
func Average[T constraints.Integer | constraints.Float](nums ...T) float64
Average returns the average of nums.
func Dim ¶ added in v2.0.2
func Dim[T constraints.Integer | constraints.Float](x, y T) T
Dim returns the maximum of x-y or 0.
func DivCeil ¶ added in v2.0.2
func DivCeil[T constraints.Integer | constraints.Float](x, y T) T
DivCeil returns the least integer value greater than or equal to x/y. If y == 0, the result will be 0.
func DivFloor ¶ added in v2.0.2
func DivFloor[T constraints.Integer | constraints.Float](x, y T) T
DivFloor returns the greatest integer value less than or equal to x/y. If y == 0, the result will be 0.
func DivRound ¶ added in v2.0.2
func DivRound[T constraints.Integer | constraints.Float](x, y T) T
DivRound returns the nearest integer, rounding half away from zero to x/y. If y == 0, the result will be 0.
func IsNegative ¶
func IsNegative[T constraints.Integer | constraints.Float](n T) bool
IsNegative returns:
true if n < 0 false if n == 0 false if n > 0
func IsNonNegative ¶
func IsNonNegative[T constraints.Integer | constraints.Float](n T) bool
IsNonNegative returns:
true if n > 0 true if n == 0 false if n < 0
func IsNonPositive ¶
func IsNonPositive[T constraints.Integer | constraints.Float](n T) bool
IsNonPositive returns:
true if n < 0 true if n == 0 false if n > 0
func IsPositive ¶
func IsPositive[T constraints.Integer | constraints.Float](n T) bool
IsPositive returns:
true if n > 0 false if n == 0 false if n < 0
func IsZero ¶
func IsZero[T constraints.Integer | constraints.Float](n T) bool
IsZero returns:
true if n == 0 false if n > 0 false if n < 0
func MaxBy ¶ added in v2.0.2
MaxBy return the largest element in slice using the given cmp function.
func MinBy ¶ added in v2.0.2
MinBy return the smallest element in slice using the given cmp function.
func Mod ¶ added in v2.0.2
func Mod[T constraints.Integer | constraints.Float](x, y T) T
Mod returns the remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x. If y == 0, the result will be 0.
func Pow ¶ added in v2.0.2
func Pow[T constraints.Integer | constraints.Float](x, y T) T
Pow returns x**y, the base-x exponential of y.
func Range ¶
func Range[T constraints.Signed | constraints.Float](start, stop T, step ...T) []T
Range returns a slice, starting from start, and increments by step, and stops before stop. If start < stop, default step is 1, else default step is -1.
func Sign ¶
func Sign[T constraints.Integer | constraints.Float](n T) int
Sign returns:
-1 if n < 0 0 if n == 0 +1 if n > 0
Types ¶
This section is empty.