operator

package
v0.0.0-...-1fb14e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[T Numeric | ~string](x, y T) T

func And

func And[T constraints.Integer](x, y T) T

func Div

func Div[T Numeric](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 Mul

func Mul[T Numeric](x, y T) T

func Neg

func Neg[T Numeric](x T) T

func Or

func Or[T constraints.Integer](x, y T) T

func Pos

func Pos[T Numeric](x T) T

func Rshift

func Rshift[T constraints.Integer](x, y T) T

func Sub

func Sub[T Numeric](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

type FuncBool[T any] func(x, y T) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL