functional

package
v0.1.202602121754 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accum_all

func Accum_all[T any, Q any](s []T, init Q, f func(T, Q) Q) Q

func Filter

func Filter[T any, Q any](s []T, f func(T) Q) []Q

func Filter_M added in v0.1.202602121754

func Filter_M[K comparable, T any, Q any](s map[K]T, f func(T) Q) map[K]Q

Filter_MtS equlivalents to Filter, but takes and returns map.

func Filter_MtS added in v0.1.202602121754

func Filter_MtS[K comparable, T any, Q any](s map[K]T, f func(T) Q) []Q

Filter_MtS equlivalents to Filter, but takes map and returns slice.

func Filter_MtS_ok added in v0.1.202602121754

func Filter_MtS_ok[K comparable, T any, Q any](s map[K]T, f func(T) (Q, bool)) []Q

Filter_MtS_ok equlivalents to Filter_ok, but takes map and returns slice.

func Filter_ok

func Filter_ok[T any, Q any](s []T, f func(T) (Q, bool)) []Q

Filter_ok takes an array and a function that returns (result, ok). The result values with ok == true is concatenated and returned.

func Filter_strict_ok

func Filter_strict_ok[T any, Q any](s []T, f func(T) (Q, bool)) ([]Q, bool)

func Filter_until_err

func Filter_until_err[T any, Q any](s []T, f func(T) (Q, error)) ([]Q, []T, error)

Filter_until_err takes an array and a function that returns a result and an error, tries to filter all entries, but stops if one call returns error. Returns result, remnant (nil if success), error When fails, the first entry of the remnant is the one which caused the error.

func Foreach

func Foreach[T any](s []T, f func(T))

func FuncReducePostfix

func FuncReducePostfix[A1, A2, R any](f func(A1, A2) R, a2 A2) func(A1) R

func FuncReducePrefix

func FuncReducePrefix[A1, A2, R any](a1 A1, f func(A1, A2) R) func(A2) R

Types

type Maybe

type Maybe[T any] struct {
	Value T
	// contains filtered or unexported fields
}

func MakeMaybe

func MakeMaybe[T any](value T) Maybe[T]

func MaybeJoin

func MaybeJoin[T, Q, R any](lhs Maybe[T], rhs Maybe[Q], f func(T, Q) (R, bool)) Maybe[R]

func MaybeYield

func MaybeYield[T, Q any](input Maybe[T], f func(T) (Q, T, bool)) (Q, Maybe[T])

func (Maybe[T]) Call

func (m Maybe[T]) Call(f func(T) (T, bool)) Maybe[T]

func (Maybe[T]) Ok

func (m Maybe[T]) Ok() bool

type MaybeErr

type MaybeErr[T any] struct {
	Value T
	// contains filtered or unexported fields
}

func (MaybeErr[T]) Call

func (m MaybeErr[T]) Call(f func(T) (T, error)) MaybeErr[T]

func (MaybeErr[T]) Err

func (m MaybeErr[T]) Err() error

type Quadruple

type Quadruple[A, B, C, D any] struct {
	A A
	B B
	C C
	D D
}

type Triple

type Triple[A, B, C any] struct {
	A A
	B B
	C C
}

type Tuple

type Tuple[A, B any] struct {
	A A
	B B
}

Jump to

Keyboard shortcuts

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