mapfun

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(K, V) (bool, error),
) (maps.Map[K, V], error)

Returns a new map containing all entries in the given map that satisfy f. All other entries are omitted.

If f returns an error, then that error is returned with the current filtered map after applying the filter to the current map entry. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.Filter.

func FilterKeys

func FilterKeys[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(K) (bool, error),
) (maps.Map[K, V], error)

Returns a new map containing all entries in the given map whose key satisfies f. All other entries are omitted.

If f returns an error, then that error is returned with the current filtered map after applying the filter to the current map key. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.FilterKeys.

func FilterKeysNoError

func FilterKeysNoError[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(K) bool,
) maps.Map[K, V]

Like FilterKeys, but without support for errors.

This is the functional version of maps.Map.FilterKeysNoError.

func FilterMap

func FilterMap[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(K, V1) (optionals.Optional[V2], error),
) (maps.Map[K, V2], error)

Returns a new map with each value replaced by f applied to the entry of that value. If f returns None, then that entry is omitted.

If f returns an error, then that error is returned with the partial map constructed thus far, after applying the filter-map to the current entry. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.FilterMap.

func FilterMapNoError

func FilterMapNoError[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(K, V1) optionals.Optional[V2],
) maps.Map[K, V2]

Like FilterMap, but without support for errors.

This is the functional version of maps.Map.FilterMapNoError.

func FilterMapValues

func FilterMapValues[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(V1) (optionals.Optional[V2], error),
) (maps.Map[K, V2], error)

Returns a new map with each value replaced by f applied to that value. If f returns None, then that value's entry is omitted.

If f returns an error, then that error is returned with the partial map constructed thus far, after applying the filter-map to the current value. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.FilterMapValues.

func FilterMapValuesNoError

func FilterMapValuesNoError[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(V1) optionals.Optional[V2],
) maps.Map[K, V2]

Like FilterMapValues, but without support for errors.

This is the functional version of maps.Map.FilterMapValuesNoError.

func FilterNoError

func FilterNoError[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(K, V) bool,
) maps.Map[K, V]

Like Filter, but without support for errors.

This is the functional version of maps.Map.FilterNoError.

func FilterValues

func FilterValues[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(V) (bool, error),
) (maps.Map[K, V], error)

Returns a new map containing all entries in the given map whose value satisfies f. All other entries are omitted.

If f returns an error, then that error is returned with the current filtered map after applying the filter to the current map value. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.FilterValues.

func FilterValuesNoError

func FilterValuesNoError[K comparable, V any](
	m maps.UnmodifiableMap[K, V],
	f func(V) bool,
) maps.Map[K, V]

Like FilterValues, but without support for errors.

This is the functional version of maps.Map.FilterValuesNoError.

func Fold

func Fold[K comparable, V any, T any](
	m maps.UnmodifiableMap[K, V],
	init T,
	f func(k K, v V, accum T) (T, error),
) (T, error)

Folds over the keys and values in the given map. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

If f returns an error, then iteration stops and that error is returned with the current accumulated value.

func FoldNoError

func FoldNoError[K comparable, V any, T any](
	m maps.UnmodifiableMap[K, V],
	init T,
	f func(k K, v V, accum T) T,
) T

Like Fold, but without support for errors.

func Map

func Map[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(V1) (V2, error),
) (maps.Map[K, V2], error)

Returns a new map with each value replaced by f applied to that value. If f returns an error, then that error is returned with the partial map constructed thus far, excluding the entry that caused the error. Map entries are processed in the same order as they appear during iteration via maps.UnmodifiableMap.Entries.

This is the functional version of maps.Map.Map.

func MapNoError

func MapNoError[K comparable, V1 any, V2 any](
	m maps.UnmodifiableMap[K, V1],
	f func(V1) V2,
) maps.Map[K, V2]

Like Map, but without support for errors.

This is the functional version of maps.Map.MapNoError.

Types

This section is empty.

Jump to

Keyboard shortcuts

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