math

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

Slice helpers

GoDev

Contains mathematic functions.

i := math.Min(10, 100) // Returns 10.

i = math.MustBetween(10, 100, 1000) // Returns 100.

Documentation

GoDoc

Documentation

Overview

Contains mathematic functions.

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 the 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 the value 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