galgorithm

package
v0.0.0-...-92667b2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValue = errors.New(`No values provided`)
)

Functions

func Abs

func Abs[T Number](n T) T

Abs returns the absolute value of n.

func Clamp

func Clamp[T constraints.Ordered](n, min, max T) T

Clamp returns n if it is in [min, max], otherwise min or max.

func InRange

func InRange[T constraints.Ordered](v, min, max T) bool

InRange returns true if v is in [min, max).

func Max

func Max[T constraints.Ordered](values ...T) T

Max returns the maximum value in values.

func Min

func Min[T constraints.Ordered](values ...T) T

Min returns the minimum value of the given values.

Types

type INumber

type INumber interface {
	Add(other INumber) INumber
	Sub(other INumber) INumber
	Mul(other INumber) INumber
	Div(other INumber) INumber
	Comp(other INumber) int
	Eq(other INumber) bool
}

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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