Help us shape the future of Go! Take the 2026 Go Developer Survey

ord

package
v1.0.113 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between[A any](O Ord[A]) func(A, A) func(A) bool

Between tests whether a value is between a minimum (inclusive) and a maximum (exclusive)

func Clamp

func Clamp[A any](o Ord[A]) func(A, A) func(A) A

Clamp clamps a value between a minimum and a maximum

func Contramap

func Contramap[A, B any](f func(B) A) func(Ord[A]) Ord[B]

Contramap creates an odering under a transformation function

func Geq

func Geq[A any](O Ord[A]) func(A) func(A) bool

Geq tests whether one value is greater or equal than another

func Gt

func Gt[A any](O Ord[A]) func(A) func(A) bool

*

  • Test whether one value is strictly greater than another

func Leq

func Leq[A any](O Ord[A]) func(A) func(A) bool

Leq Tests whether one value is less or equal than another

func Lt

func Lt[A any](O Ord[A]) func(A) func(A) bool

Lt tests whether one value is strictly less than another

func Max

func Max[A any](o Ord[A]) func(A, A) A

Max takes the maximum of two values. If they are considered equal, the first argument is chosen

func MaxSemigroup

func MaxSemigroup[A any](O Ord[A]) S.Semigroup[A]

MaxSemigroup returns a semigroup where `concat` will return the maximum, based on the provided order.

func Min

func Min[A any](o Ord[A]) func(A, A) A

Min takes the minimum of two values. If they are considered equal, the first argument is chosen

func MinSemigroup

func MinSemigroup[A any](O Ord[A]) S.Semigroup[A]

MaxSemigroup returns a semigroup where `concat` will return the minimum, based on the provided order.

func Monoid

func Monoid[A any]() M.Monoid[Ord[A]]

Monoid implements a two level ordering such that - its `Concat(ord1, ord2)` operation will order first by `ord1`, and then by `ord2` - its `Empty` value is an `Ord` that always considers compared elements equal

func Semigroup

func Semigroup[A any]() S.Semigroup[Ord[A]]

Semigroup implements a two level ordering

func ToEq added in v1.0.19

func ToEq[T any](o Ord[T]) E.Eq[T]

ToEq converts an Ord to [E.Eq]

Types

type Ord

type Ord[T any] interface {
	E.Eq[T]
	Compare(x, y T) int
}

func FromCompare

func FromCompare[T any](compare func(T, T) int) Ord[T]

MakeOrd creates an instance of an Ord from a compare function

func FromStrictCompare

func FromStrictCompare[A C.Ordered]() Ord[A]

FromStrictCompare implements the ordering based on the built in native order

func MakeOrd

func MakeOrd[T any](c func(x, y T) int, e func(x, y T) bool) Ord[T]

MakeOrd creates an instance of an Ord

func Reverse

func Reverse[T any](o Ord[T]) Ord[T]

Reverse creates an inverted ordering

Jump to

Keyboard shortcuts

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