functional

package module
v0.0.0-...-8f5b7b3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

functional implements functional programming utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](ts []T, f func(t T) bool) bool

All Returns true if f(t) == true for all t in ts.

func Any

func Any[T any](ts []T, f func(t T) bool) bool

Any returns true if f(t) == true for any t in ts.

func Count

func Count[T comparable](ts []T, k T) int

func Count2D

func Count2D[T comparable](tss [][]T, k T) int

func Count2DFunc

func Count2DFunc[T any](tss [][]T, f func(T) bool) int

func CountFunc

func CountFunc[T any](ts []T, f func(T) bool) int

func Filter

func Filter[T any](ts []T, f func(t T) bool) []T

func Flat

func Flat[T comparable](tts [][]T) []T

func If

func If[T any](v bool, t, f T) T

If returns t if v is true; f otherwise

func Map

func Map[I, O any](items []I, f func(I) O) []O

Map maps all of the elements in `items` with the function f.

func MapWithIndex

func MapWithIndex[I, O any](items []I, f func(int, I) O) []O

MapWithIndex maps all of the elements in `items` with function f.

func None

func None[T any](ts []T, f func(t T) bool) bool

None returns true if f(t) == false for all t in ts.

func Reduce

func Reduce[B, T any](base B, items []T, f func(B, T) B) B

Reduce reduces `base` across `items` with function f.

func SortFunc

func SortFunc[T any](items []T, lessFunc func(T, T) bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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