single

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect[T, U any](s sequence.Sequence[T], initial U, process func(T, U) U) (U, error)

Collect produces a single value from a sequence. It starts with an initial output value, and for every item in the sequence the value is permuted by the process function using the item from the sequence and the current value.

func CollectErr

func CollectErr[T, U any](s sequence.Sequence[T], initial U, process func(T, U) (U, error)) (U, error)

CollectErr produces a single value from a sequence. It starts with an initial output value, and for every item in the sequence the value is permuted by the process function using the item from the sequence and the current value.

The callback may return errors to stop processing, either to indicate failure, or in the case of ErrStopIteration to simply end processing.

func Error

func Error[T any](err error) sequence.Sequence[T]

Error returns a sequence where the given error is return when iterated upon.

func Infinite

func Infinite[T any](t T) sequence.Sequence[T]

Infinite generates a sequence where the given value is returned forever, on each iteration of the sequence.

func Repeat

func Repeat[T any](t T, n int) sequence.Sequence[T]

Repeat generates a sequence where the given item is returns a fixed number of times.

func Single

func Single[T any](t T) sequence.Sequence[T]

Single returns a sequence where the given value is returned once.

Types

This section is empty.

Jump to

Keyboard shortcuts

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