Documentation
¶
Overview ¶
mathx - a package with common arithmetic operations. Almost useless in simple use-cases, but might be useful in complex (like combinations with slice package).
Index ¶
- func Div[T constraints.Integer | constraints.Float](vals ...T) T
- func DivRuntime(vals ...any) any
- func Mul[T constraints.Integer | constraints.Float](vals ...T) T
- func MulRuntime(vals ...any) any
- func Sub[T constraints.Integer | constraints.Float](vals ...T) T
- func SubRuntime(vals ...any) any
- func Sum[T constraints.Integer | constraints.Float | string](vals ...T) T
- func SumRuntime(vals ...any) any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Div ¶
func Div[T constraints.Integer | constraints.Float](vals ...T) T
Div returns the division of the first value to the second and later. Makes no sense in unual use-cases, but useful in templates.
Usage:
mathx.Div(5, 2, 2) // 1.25 mathx.Div([]int{5, 2, 2}...) // 1.25
func DivRuntime ¶
DivRuntime is a runtime version of arithmetic.Div.
func Mul ¶
func Mul[T constraints.Integer | constraints.Float](vals ...T) T
Mul returns the multiplication result of the given values.
Usage:
mathx.Mul(1, 2, 3) // 6 mathx.Mul([]float64{3.4, 6.5, 4.3}...) // 95.03
func MulRuntime ¶
MulRuntime is a runtime version of arithmetic.Mul.
func Sub ¶
func Sub[T constraints.Integer | constraints.Float](vals ...T) T
Sub returns the subtraction of the given values from the first one.
Usage:
mathx.Sub(4, 2, 1) // 1 mathx.Sub([]float64{5.4, 3, 1}...) // 1.4
func SubRuntime ¶
SubRuntime is a runtime version of arithmetic.Sub.
func Sum ¶
func Sum[T constraints.Integer | constraints.Float | string](vals ...T) T
Sum returns the sum of the given values.
Usage:
mathx.Sum(4, 2, 1) // 7 mathx.Sum([]float64{5.4, 3, 1}...) // 9.4
func SumRuntime ¶
SumRuntime is a runtime version of arithmetic.Sum.
Types ¶
This section is empty.