stateless

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stateless defines a stateless (pure) iterator, i.e. one that can be iterated over multiple times without side effects, it is threadsafe

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap added in v1.0.7

func Ap[V, U any](ma Iterator[U]) func(Iterator[func(U) V]) Iterator[V]

Ap is the applicative functor for iterators

func Chain

func Chain[U, V any](f func(U) Iterator[V]) func(Iterator[U]) Iterator[V]

func Filter added in v1.0.7

func Filter[U any](f func(U) bool) func(ma Iterator[U]) Iterator[U]

Filter filters the content of an iterator

func FilterMap added in v1.0.7

func FilterMap[U, V any](f func(U) O.Option[V]) func(ma Iterator[U]) Iterator[V]

FilterMap filters and transforms the content of an iterator

func Map

func Map[U, V any](f func(U) V) func(ma Iterator[U]) Iterator[V]

Map transforms an Iterator of type [U] into an Iterator of type [V] via a mapping function

func Monoid

func Monoid[U any]() M.Monoid[Iterator[U]]

Monoid contructs a [M.Monoid] that concatenates two [Iterator]s

func Reduce

func Reduce[U, V any](f func(V, U) V, initial V) func(Iterator[U]) V

Reduce applies a function for each value of the iterator with a floating result

func ToArray

func ToArray[U any](u Iterator[U]) []U

ToArray converts the iterator to an array

Types

type Iterator

type Iterator[U any] L.Lazy[O.Option[T.Tuple2[Iterator[U], U]]]

Iterator represents a stateless, pure way to iterate over a sequence

func Empty

func Empty[U any]() Iterator[U]

Empty returns the empty iterator

func Flatten

func Flatten[U any](ma Iterator[Iterator[U]]) Iterator[U]

Flatten converts an Iterator of Iterator into a simple Iterator

func From added in v1.0.7

func From[U any](data ...U) Iterator[U]

From constructs an Iterator from a set of variadic arguments

func FromArray

func FromArray[U any](as []U) Iterator[U]

FromArray returns an iterator from multiple elements

func MakeBy

func MakeBy[FCT ~func(int) U, U any](n int, f FCT) Iterator[U]

MakeBy returns an Iterator with `n` elements initialized with `f(i)`

func MonadAp added in v1.0.7

func MonadAp[V, U any](fab Iterator[func(U) V], ma Iterator[U]) Iterator[V]

MonadAp is the applicative functor for iterators

func MonadChain

func MonadChain[U, V any](ma Iterator[U], f func(U) Iterator[V]) Iterator[V]

func MonadMap

func MonadMap[U, V any](ma Iterator[U], f func(U) V) Iterator[V]

MonadMap transforms an Iterator of type [U] into an Iterator of type [V] via a mapping function

func Of

func Of[U any](a U) Iterator[U]

Of returns an iterator with one single element

func Replicate

func Replicate[U any](n int, a U) Iterator[U]

Replicate creates an Iterator containing a value repeated the specified number of times.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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