math

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

Slice helpers

GoDev

Contains mathematic functions.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

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

Between returns true if value is between max and min.

Example
fmt.Println(Between(1, 10, 100))
fmt.Println(Between(110, 10, 100))
fmt.Println(Between(11, 10, 100))
Output:

false
false
true

func Max

func Max[T constraints.Ordered](v1, v2 T) T

Max returns maximum value.

Example
fmt.Println(Max(1, 10))
fmt.Println(Max(11, 10))
Output:

10
11

func Min

func Min[T constraints.Ordered](v1, v2 T) T

Min returns minimum value.

Example
fmt.Println(Min(1, 10))
fmt.Println(Min(11, 10))
Output:

1
10

func MustBetween

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

MustBetween returns true if value is between max and min.

Example
fmt.Println(MustBetween(1, 10, 100))
fmt.Println(MustBetween(11, 10, 100))
fmt.Println(MustBetween(110, 10, 100))
Output:

10
11
100

Types

This section is empty.

Jump to

Keyboard shortcuts

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