basics

package
v0.0.0-...-608ba51 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](in []T, fn comb.Predicate[T]) []T

Filter applies a predicate function to filter elements of a slice and returns the filtered slice.

func Find

func Find[T any](in []T, fn comb.Predicate[T]) (T, bool)

Find applies a predicate function to find the first element in a slice that satisfies the condition. It returns the found element and a boolean indicating if an element was found.

func FoldLeft

func FoldLeft[In, Out any](
	in []In, from Out, fn comb.Folder[In, Out],
) Out

FoldLeft applies a reduction function to reduce elements of a slice to a single result value, starting from an initial value, operating on the elements of the slice from left to right.

func FoldRight

func FoldRight[In, Out any](
	in []In, from Out, fn comb.Folder[In, Out],
) Out

FoldRight applies a reduction function to reduce elements of a slice to a single result value, starting from an initial value, operating on the elements of the slice from right to left.

func IndexedMap

func IndexedMap[In any, Out any](
	in []In, fn slices.IndexedMapper[In, Out],
) []Out

IndexedMap applies an indexed mapping function to transform elements of a slice and returns the mapped slice.

func Map

func Map[In, Out any](in []In, fn comb.Mapper[In, Out]) []Out

Map applies a mapping function to transform elements of a slice and returns the mapped slice.

func MapKeys

func MapKeys[K comparable, V any](in map[K]V) []K

MapKeys extracts and returns the keys of a map as a slice, panicking if an error occurs

func MapValues

func MapValues[K comparable, V any](in map[K]V) []V

MapValues extracts and returns the values of a map as a slice, panicking if an error occurs.

func Sort

func Sort[T cmp.Ordered](in []T) []T

Sort sorts the elements of a slice and returns the sorted slice.

func SortFunc

func SortFunc[T any](in []T, fn slices.Compare[T]) []T

SortFunc sorts the elements of a slice using a custom comparison function and returns the sorted slice.

func SortedKeys

func SortedKeys[K cmp.Ordered, V any](in map[K]V) []K

SortedKeys extracts and returns the keys of a map as a sorted slice, panicking if an error occurs.

func SortedKeysFunc

func SortedKeysFunc[K comparable, V any](
	in map[K]V, fn slices.Compare[K],
) []K

SortedKeysFunc extracts and returns the keys of a map as a sorted slice using a custom comparison function, panicking if an error occurs.

func SortedMap

func SortedMap[In any, Out cmp.Ordered](
	in []In, fn comb.Mapper[In, Out],
) []Out

SortedMap applies a mapping function to transform elements of a slice and returns the sorted mapped slice.

func SortedMapFunc

func SortedMapFunc[In any, Out cmp.Ordered](
	in []In, fn comb.Mapper[In, Out], comp slices.Compare[Out],
) []Out

SortedMapFunc applies a mapping function to transform elements of a slice and returns the sorted mapped slice using a custom comparison function for sorting.

func SortedValues

func SortedValues[K comparable, V cmp.Ordered](in map[K]V) []V

SortedValues extracts and returns the values of a map as a sorted slice, panicking if an error occurs.

func SortedValuesFunc

func SortedValuesFunc[K comparable, V any](
	in map[K]V, fn slices.Compare[V],
) []V

SortedValuesFunc extracts and returns the values of a map as a sorted slice using a custom comparison function, panicking if an error occurs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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