Documentation
¶
Overview ¶
Package operator provides a set of generic functions corresponding to the intrinsic operators of Golang.
For example, operator.Add(x, y) is equivalent to the expression x + y. This is similar to Python's operator module provided in the standard library.
Index ¶
- func Add[T Numeric | ~string](x, y T) T
- func And[T constraints.Integer](x, y T) T
- func Div[T Numeric](x, y T) T
- func Eq[T comparable](x, y T) bool
- func Ge[T constraints.Ordered](x, y T) bool
- func Gt[T constraints.Ordered](x, y T) bool
- func Le[T constraints.Ordered](x, y T) bool
- func Lshift[T constraints.Integer](x, y T) T
- func Lt[T constraints.Ordered](x, y T) bool
- func Mod[T constraints.Integer](x, y T) T
- func Mul[T Numeric](x, y T) T
- func Neg[T Numeric](x T) T
- func Or[T constraints.Integer](x, y T) T
- func Pos[T Numeric](x T) T
- func Rshift[T constraints.Integer](x, y T) T
- func Sub[T Numeric](x, y T) T
- func Xor[T constraints.Integer](x, y T) T
- type Func1
- type Func2
- type FuncBool
- type Numeric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[T constraints.Integer](x, y T) T
func Eq ¶
func Eq[T comparable](x, y T) bool
func Ge ¶
func Ge[T constraints.Ordered](x, y T) bool
func Gt ¶
func Gt[T constraints.Ordered](x, y T) bool
func Le ¶
func Le[T constraints.Ordered](x, y T) bool
func Lshift ¶
func Lshift[T constraints.Integer](x, y T) T
func Lt ¶
func Lt[T constraints.Ordered](x, y T) bool
func Mod ¶
func Mod[T constraints.Integer](x, y T) T
func Or ¶
func Or[T constraints.Integer](x, y T) T
func Rshift ¶
func Rshift[T constraints.Integer](x, y T) T
func Xor ¶
func Xor[T constraints.Integer](x, y T) T
Types ¶
type Func1 ¶
type Func1[T any] func(x T) T
Func1 is a function which accepts a single parameter of any type and returns a value of the same type.
type Func2 ¶
type Func2[T any] func(x, y T) T
Func2 is a function which accepts two parameters of any type and returns a value of the same type.
type FuncBool ¶
FuncBool is a function which accepts two parameters of any type and returns a boolean value.
type Numeric ¶
type Numeric interface { constraints.Integer | constraints.Float | constraints.Complex }
Numeric is a constraint that permits any numeric type. This includes all signed and unsigned integer, floating-point and complex numeric type.