math

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

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce

func Coalesce[T comparable](v ...T) (result T, ok bool)

Coalesce returns the first non-empty arguments. Arguments must be comparable.

func GetValueNotEmptyOrDefault

func GetValueNotEmptyOrDefault[T constraints.Ordered](value, defaultValue T) T

GetValueNotEmptyOrDefault return defaultValue if value is zeroValue, else return value

func Max

func Max[T constraints.Ordered](x, y T) T

func Min

func Min[T constraints.Ordered](x T, y T) T

func Sum

func Sum[T constraints.Integer | constraints.Float](slices []T) T

Sum return sum of array number

func TernaryF

func TernaryF[T any](condition bool, ifFunc func() T, elseFunc func() T) T

TernaryF is a 1 line if/else statement whose options are functions Play: https://go.dev/play/p/AO4VW20JoqM

func TernaryOp

func TernaryOp[T any](condition bool, ifOutput T, elseOutput T) T

TernaryOp represent for e1 ? e2 : e3

Types

This section is empty.

Jump to

Keyboard shortcuts

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