fp

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package fp provides functional programming helpers such as Map, Filter, and Apply for working with slices and callables in a generic, type-safe way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[T any](startVal T, callables ...func(T) T) T

Apply applies each callable to startVal in turn, returning the final value.

func ApplyE

func ApplyE[T any](startVal T, callables ...func(T) (T, error)) (T, error)

ApplyE applies each callable to startVal in turn, short-circuiting and returning an error if a callable fails.

func Filter

func Filter[T any](predicate func(T) bool, vals []T) []T

Filter returns the elements of vals for which predicate returns true.

func FilterE

func FilterE[T any](predicate func(T) (bool, error), vals []T) ([]T, error)

FilterE returns the elements of vals for which predicate returns true, short-circuiting and returning an error if predicate fails.

func Map

func Map[T, P any](callable func(T) P, vals []T) []P

Map applies callable to each element of vals and returns a new slice of the results.

func MapE

func MapE[T, P any](callable func(T) (P, error), vals []T) ([]P, error)

MapE applies callable to each element of vals and returns a new slice of the results, short-circuiting and returning an error if callable fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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