iterslice

package
v0.0.0-...-df563a6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(l, r int) iter.Seq[int]

Between iterates between l and r (exclusive) and yield values as iter.Seq[int].

func Chars

func Chars(s string) iter.Seq[string]

Chars iterate over string and returns runes as iter.Seq[string].

func ConsumeChannel

func ConsumeChannel[T any](c <-chan T) iter.Seq[T]

ConsumeChannel reads from channel until it closes and yield values as iter.Seq[T].

func Each

func Each[T any, F ~func(T)](seq iter.Seq[T], f F)

Each iterates over iter.Seq[T] and applies F to each element.

func Filter

func Filter[T any, F ~func(T) bool](seq iter.Seq[T], f F) iter.Seq[T]

Filter filters iter.Seq[T] with F and returns iter.Seq[T] containing only those values for which F returns true.

func First

func First[T any](seq iter.Seq[T]) (T, bool)

First gets the first element from iter.Seq[T] and returns (T, bool).

func Iterator

func Iterator[T any](s []T) iter.Seq[T]

Iterator creates iter.Seq[T] from any []T.

func Join

func Join[T any](iters ...iter.Seq[T]) iter.Seq[T]

Join N iter.Seq[T] to one iterator.

func Last

func Last[T any](seq iter.Seq[T]) (T, bool)

Last gets the last element from iter.Seq[T] and returns (T, bool).

func Map

func Map[T any, E any, F ~func(T) E](seq iter.Seq[T], f F) iter.Seq[E]

Map maps iter.Seq[T] with F and return iter.Seq[E].

func Max

func Max[T constraints.Ordered](seq iter.Seq[T]) T

Max finds maximum element in an iter.Seq[T].

func Min

func Min[T constraints.Ordered](seq iter.Seq[T]) T

Min finds minimum element in an iter.Seq[T].

func Nth

func Nth[T any](seq iter.Seq[T], n uint) (T, bool)

Nth gets the N element from iter.Seq[T] and returns (T, bool). N starts from 1.

func Partition

func Partition[T any, F ~func(T) bool](seq iter.Seq[T], f F) (iter.Seq[T], iter.Seq[T])

Partition consumes an iter.Seq[T], creating two iterators from it.

func Position

func Position[T comparable](seq iter.Seq[T], i T) (int, bool)

Position searches for an element in an iter.Seq[T], returning its index.

func Range

func Range(n int) iter.Seq[int]

Range iterates over an integer and yield values as iter.Seq[int].

func Reduce

func Reduce[T any, A ~func(T, T) T](seq iter.Seq[T], a A, initial ...T) T

Reduce reduce iter.Seq[T] with A and returns single value. Optional accepts initial.

func Split

func Split(s string, sep string) iter.Seq[string]

Split splits string using separator and yield chunks as iter.Seq[string].

func TryMap

func TryMap[T any, E any, F ~func(T) (E, error)](seq iter.Seq[T], f F) iter.Seq2[E, error]

TryMap tries to convert T to E using F and returns iter.Seq2[T, error].

Types

This section is empty.

Jump to

Keyboard shortcuts

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