iter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT-0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[Item any](seq Seq[Item], pred Pred[Item]) bool

All returns whether the specified predicate matches all items in the specified sequence.

func All2

func All2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) bool

All2 returns whether the specified predicate matches all pairs in the specified sequence.

func And

func And(seq Seq[bool]) bool

And returns the logical AND of the boolean values in the specified sequence. The evaluation is short-circuiting.

func Any

func Any[Item any](seq Seq[Item], pred Pred[Item]) bool

Any returns whether the specified predicate matches any items in the specified sequence.

func Any2

func Any2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) bool

func Empty

func Empty[Item any](yield func(Item) bool)

Empty is an empty sequence of items.

func Empty2

func Empty2[Item1, Item2 any](yield func(Item1, Item2) bool)

Empty2 is an empty sequence of pairs.

func EmptyMux2 added in v1.0.0

func EmptyMux2[Item1, Item2 any](yield1 func(Item1) bool, yield2 func(Item2) bool)

EmptyMux2 is an empty sequence of 2-way heterogeneous items.

func EmptyMux3 added in v1.0.0

func EmptyMux3[Item1, Item2, Item3 any](yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool)

EmptyMux3 is an empty sequence of 3-way heterogeneous items.

func EmptyMux4 added in v1.0.0

func EmptyMux4[Item1, Item2, Item3, Item4 any](yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool, yield4 func(Item4) bool)

EmptyMux4 is an empty sequence of 4-way heterogeneous items.

func First

func First[Item any](seq Seq[Item]) (Item, bool)

First returns the first item of the specified sequence and true, or the zero value for [Item] and false if the sequence is empty.

func First2

func First2[Item1, Item2 any](seq Seq2[Item1, Item2]) (Item1, Item2, bool)

First2 returns the first pair of the specified sequence and true, or the zero value for [Item1] and [Item2], and false if the sequence is empty.

func Fold

func Fold[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) Result) Result

Fold returns the result of successively applying the specified combining function to items from the specified sequence, starting with the seed value. When the sequence is empty, the result will be the seed value.

func Fold2

func Fold2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) Result) Result

Fold2 returns the result of successively applying the specified combining function to pairs from the specified sequence, starting with the seed value. When the sequence is empty, the result will be the seed value.

func FoldWhile added in v1.0.0

func FoldWhile[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) (Result, bool)) Result

FoldWhile returns the result of successively applying the specified combining function to items from the specified sequence while its second return value is true, starting with the seed value. When the sequence is empty, the result will be the seed value.

TL;DR: it's Fold with early return.

func FoldWhile2 added in v1.0.0

func FoldWhile2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) (Result, bool)) Result

FoldWhile2 returns the result of successively applying the specified combining function to pairs from the specified sequence while its second return value is true, starting with the seed value. When the sequence is empty, the result will be the seed value.

TL;DR: it's Fold2 with early return.

func IsEmpty

func IsEmpty[Item any](seq Seq[Item]) bool

IsEmpty returns whether the specified sequence has no items.

func IsEmpty2

func IsEmpty2[Item1, Item2 any](seq Seq2[Item1, Item2]) bool

IsEmpty2 returns whether the specified sequence has no pairs.

func Last

func Last[Item any](seq Seq[Item]) (last Item, hasLast bool)

Last returns the last item of the specified non-empty sequence and true. When the specified sequence is empty, it returns the zero value for [Item] and false.

func Last2

func Last2[Item1, Item2 any](seq Seq2[Item1, Item2]) (last1 Item1, last2 Item2, hasLast bool)

Last2 returns the last pair of the specified non-empty sequence and true. When the specified sequence is empty, it return the zero values for [Item1] and [Item2], and false.

func Len

func Len[Item any](seq Seq[Item]) (cnt int)

Len returns the length of the specified sequence by counting its items.

func Len2

func Len2[Item1, Item2 any](seq Seq2[Item1, Item2]) (cnt int)

Len2 returns the length of the sequence by counting its pairs.

func Max added in v1.0.0

func Max[Item cmp.Ordered](seq Seq[Item]) Item

Max returns the largest item in the specified sequence. It returns the zero value for Item when the sequence is empty.

func Min added in v1.0.0

func Min[Item cmp.Ordered](seq Seq[Item]) Item

Min returns the smallest item in the specified sequence. It returns the zero value for Item when the sequence is empty.

func Or

func Or(seq Seq[bool]) bool

Or returns the logical OR of the boolean values in the specified sequence. The evaluation is short-circuiting.

func Pull

func Pull[V any](seq Seq[V]) (next func() (V, bool), stop func())

func Pull2

func Pull2[K, V any](seq Seq2[K, V]) (next func() (K, V, bool), stop func())

func PullMany

func PullMany[Item any](seqs ...Seq[Item]) (next func() ([]Item, bool), stop func())

PullMany is like Pull for many sequences: it converts the specified “push-style” sequences into a “pull-style” iterator, pulling items from the sequences in lock-step. Next returns with false when any of the sequences is exhausted.

func PullMany2

func PullMany2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) (next func() ([]Item1, []Item2, bool), stop func())

PullMany2 is like Pull2 for many sequences: it converts the specified “push-style” sequences into a “pull-style” iterator, pulling pairs from the sequences in lock-step. Next returns with false when any of the sequences is exhausted.

func Reduce

func Reduce[Item any](seq Seq[Item], combine func(Item, Item) Item) (res Item)

Reduce returns the result of successively applying the specified combining function to items from the specified sequence. When the sequence is empty, the result will be the zero value for Item. When the sequence has a single item, that item will be the result.

func Reduce2

func Reduce2[Item1, Item2 any](seq Seq2[Item1, Item2], combine func(Item1, Item2, Item1, Item2) (Item1, Item2)) (res1 Item1, res2 Item2)

Reduce2 returns the result of successively applying the specified combining function to pairs from the specified sequence. When the sequence is empty, the result will be the zero values for Item1 and Item2. When the sequence has a single pair, that pair will be the result.

func ReduceWhile added in v1.0.0

func ReduceWhile[Item any](seq Seq[Item], combine func(Item, Item) (Item, bool)) Item

ReduceWhile returns the result of successively applying the specified combining function to items from the specified sequence while its second return value is true. When the sequence is empty, the result will be the zero value for Item. When the sequence has a single item, that item will be the result.

TL;DR: it's Reduce with early return.

func ReduceWhile2 added in v1.0.0

func ReduceWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], combine func(Item1, Item2, Item1, Item2) (Item1, Item2, bool)) (Item1, Item2)

ReduceWhile2 returns the result of successively applying the specified combining function to pairs from the specified sequence while its third return value is true. When the sequence is empty, the result will be the zero value for Item1 and Item2. When the sequence has a single pair, that pair will be the result.

TL;DR: it's Reduce2 with early return.

func Sum

func Sum[Item Summable](seq Seq[Item]) Item

Sum returns the sum of items in the specified sequence.

func Unzip

func Unzip[Item1, Item2 any](seq Seq2[Item1, Item2]) (Seq[Item1], Seq[Item2])

Unzip returns two sequences that iterate over the first and second items of the specified sequence of pairs, respectively.

func YieldAll added in v1.0.0

func YieldAll[Item any](seq Seq[Item], yield func(Item) bool) bool

YieldAll yields all items from the specified sequence using the specified function. It returns false if yield returned false.

This can be useful when forwarding enumeration to a child sequence or emulating Python's for-else.

func YieldAll2 added in v1.0.0

func YieldAll2[Item1, Item2 any](seq Seq2[Item1, Item2], yield func(Item1, Item2) bool) bool

YieldAll2 yields all pairs from the specified sequence using the specified function. It returns false if yield returned false.

This can be useful when forwarding enumeration to a child sequence or emulating Python's for-else.

Types

type MuxSeq2 added in v1.0.0

type MuxSeq2[Item1, Item2 any] func(yield1 func(Item1) bool, yield2 func(Item2) bool)

MuxSeq2 represents a 2-way heterogeneous sequence of values.

func DemuxMap2 added in v1.0.0

func DemuxMap2[ItemIn, ItemOut1, ItemOut2 any](seq Seq[ItemIn], demux func(item ItemIn, k1 func(ItemOut1), k2 func(ItemOut2))) MuxSeq2[ItemOut1, ItemOut2]

DemuxMap2 turns a sequence of homogeneous (in type) items into a sequence of 2-way heterogeneous items by using the specified demultiplexing function.

type MuxSeq3 added in v1.0.0

type MuxSeq3[Item1, Item2, Item3 any] func(yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool)

MuxSeq3 represents a 3-way heterogeneous sequence of values.

func DemuxMap3 added in v1.0.0

func DemuxMap3[ItemIn, ItemOut1, ItemOut2, ItemOut3 any](seq Seq[ItemIn], demux func(item ItemIn, k1 func(ItemOut1), k2 func(ItemOut2), k3 func(ItemOut3))) MuxSeq3[ItemOut1, ItemOut2, ItemOut3]

DemuxMap3 turns a sequence of homogeneous (in type) items into a sequence of 3-way heterogeneous items by using the specified demultiplexing function.

type MuxSeq4 added in v1.0.0

type MuxSeq4[Item1, Item2, Item3, Item4 any] func(yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool, yield4 func(Item4) bool)

MuxSeq4 represents a 4-way heterogeneous sequence of values.

func DemuxMap4 added in v1.0.0

func DemuxMap4[ItemIn, ItemOut1, ItemOut2, ItemOut3, ItemOut4 any](seq Seq[ItemIn], demux func(item ItemIn, k1 func(ItemOut1), k2 func(ItemOut2), k3 func(ItemOut3), k4 func(ItemOut4))) MuxSeq4[ItemOut1, ItemOut2, ItemOut3, ItemOut4]

DemuxMap4 turns a sequence of homogeneous (in type) items into a sequence of 4-way heterogeneous items by using the specified demultiplexing function.

type Pred added in v1.0.0

type Pred[Value any] = internal.Pred[Value]

type Pred2 added in v1.0.0

type Pred2[Value1, Value2 any] = internal.Pred2[Value1, Value2]

type Seq

type Seq[V any] = iter.Seq[V]

func Concat

func Concat[Item any](seqs ...Seq[Item]) Seq[Item]

Concat returns a sequence of items that is the concatenation of items from the specified sequences.

func Count

func Count[Item Summable](from Item, step Item) Seq[Item]

Count returns a sequence of repeatedly adding step to the previous value, starting with from.

func Cycle

func Cycle[Item any](seq Seq[Item]) Seq[Item]

Cycle returns a sequence of items that infinitely repeates the specified sequence.

func Divvy

func Divvy[Item any](seq Seq[Item], size int, skip int) Seq[[]Item]

Divvy returns a sequence of slices with at most size length containing a continuous range of items from the specified sequence. The start of each slice will be offset by skip number of items from the previous one. Slices will overlap when size > skip, and some items will be dropped when size < skip.

func DivvyExact

func DivvyExact[Item any](seq Seq[Item], size int, skip int) Seq[[]Item]

DivvyExact is like Divvy but all yielded slices are exactly size length. Any trailing items are dropped.

func Drop added in v1.0.0

func Drop[Item any](seq Seq[Item], n int) Seq[Item]

Drop returns a sequence with at most n items dropped from the start of the specified sequence.

func DropLast added in v1.0.0

func DropLast[Item any](seq Seq[Item], n int) Seq[Item]

DropLast returns the specified sequence of items without its last n items. When the specified sequence has less than n items, the result will be empty.

Uses O(n) space.

func DropWhile added in v1.0.0

func DropWhile[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]

DropWhile returns the rest of the specified sequence after the prefix of items matching the specified predicate.

func Filter

func Filter[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]

Filter returns a sequence of items that only contains items of the specified sequence that match the specified predicate.

func FilterMap

func FilterMap[ItemIn, ItemOut any](seq Seq[ItemIn], mapFn func(ItemIn) (ItemOut, bool)) Seq[ItemOut]

FilterMap returns a sequence that only contains transformed items of the specified sequence where the specified function returned true.

func Flatten

func Flatten[Item any](seqs Seq[Seq[Item]]) Seq[Item]

Flatten returns the concatenation of sequences yielded by the specified sequence.

func Folds

func Folds[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) Result) Seq[Result]

Folds returns a sequence of partial results of successively applying the specified combining function to items from the specified sequence, starting with the seed value.

func Folds2

func Folds2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) Result) Seq[Result]

Folds2 returns a sequence of partial results of successively applying the specified combining function to pairs from the specified sequence, starting with the seed value.

func FoldsWhile added in v1.0.0

func FoldsWhile[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) (Result, bool)) Seq[Result]

FoldsWhile returns a sequence of partial results of successively applying the specified combining function to items from the specified sequence while its second return value is true, starting with the seed value.

TL;DR: it's Folds with early return.

func FoldsWhile2 added in v1.0.0

func FoldsWhile2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) (Result, bool)) Seq[Result]

FoldsWhile2 returns a sequence of partial results of successively applying the specified combining function to pairs from the specified sequence while its second return value is true, starting with the seed value.

TL;DR: it's Folds2 with early return.

func FromValues

func FromValues[Item any](values ...Item) Seq[Item]

FromValues returns a sequence that yields the specified values.

func Generate added in v1.0.0

func Generate[Item any](next func() Item) Seq[Item]

Generate returns a sequence of items obtained by calling the specified function repeatedly.

func GenerateWhile added in v1.0.0

func GenerateWhile[Item any](next func() (Item, bool)) Seq[Item]

Generate returns a sequence of items obtained by calling the specified function repeatedly until it returns false.

The item returned with false will not be yielded.

func Inspect added in v1.0.0

func Inspect[Item any](seq Seq[Item], observe func(Item)) Seq[Item]

Inspect returns a sequence whose items are the same as the specified sequence's but are passed to the specified function before being yielded.

func Interleave

func Interleave[Item any](seqs ...Seq[Item]) Seq[Item]

Interleave returns a sequence of items obtained by cycling between the specified sequences for each item. When any of the input sequences is exhausted the sequence ends.

func Intersperse added in v1.0.0

func Intersperse[Item any](seq Seq[Item], sep Item) Seq[Item]

Intersperse returns a sequence of items where separators are inserted between items from the specified sequence.

func Map

func Map[ItemIn, ItemOut any](seq Seq[ItemIn], mapFn func(ItemIn) ItemOut) Seq[ItemOut]

Map returns a sequence of items obtained by transforming each item of the specified sequence using the specified function.

func Memoize

func Memoize[Item any](seq Seq[Item]) Seq[Item]

Memoize returns a sequence of items that yields memoized items from the specified underlying sequence. Each item of the specified sequence will only be forced at most once.

func MuxMap2 added in v1.0.0

func MuxMap2[ItemIn1, ItemIn2, ItemOut any](seq MuxSeq2[ItemIn1, ItemIn2], mux1 func(ItemIn1) ItemOut, mux2 func(ItemIn2) ItemOut) Seq[ItemOut]

MuxMap2 turns a sequence of 2-way heterogeous items into a sequence of homogeneous items by using the specified multiplexing functions.

func MuxMap3 added in v1.0.0

func MuxMap3[ItemIn1, ItemIn2, ItemIn3, ItemOut any](seq MuxSeq3[ItemIn1, ItemIn2, ItemIn3], mux1 func(ItemIn1) ItemOut, mux2 func(ItemIn2) ItemOut, mux3 func(ItemIn3) ItemOut) Seq[ItemOut]

MuxMap3 turns a sequence of 3-way heterogeous items into a sequence of homogeneous items by using the specified multiplexing functions.

func MuxMap4 added in v1.0.0

func MuxMap4[ItemIn1, ItemIn2, ItemIn3, ItemIn4, ItemOut any](seq MuxSeq4[ItemIn1, ItemIn2, ItemIn3, ItemIn4], mux1 func(ItemIn1) ItemOut, mux2 func(ItemIn2) ItemOut, mux3 func(ItemIn3) ItemOut, mux4 func(ItemIn4) ItemOut) Seq[ItemOut]

MuxMap4 turns a sequence of 4-way heterogeous items into a sequence of homogeneous items by using the specified multiplexing functions.

func PackMap

func PackMap[ItemIn1, ItemIn2, ItemOut any](seq Seq2[ItemIn1, ItemIn2], pack func(ItemIn1, ItemIn2) ItemOut) Seq[ItemOut]

PackMap returns a sequence of items where each item is the result of packing a pair of values from the specified sequence using the specified function.

func Panic added in v1.0.0

func Panic[Item any](reason any) Seq[Item]

Panic returns a sequence of items that panics with the specified reason when enumerated.

func Reductions

func Reductions[Item any](seq Seq[Item], combine func(Item, Item) Item) Seq[Item]

Reductions returns a sequence of partial results of successively applying the specified combining function to items from the specified sequence. The first item of the returned sequence will be the first item of the specified sequence. When the specified sequence is empty, the returned sequence will be empty.

func ReductionsWhile added in v1.0.0

func ReductionsWhile[Item any](seq Seq[Item], combine func(Item, Item) (Item, bool)) Seq[Item]

ReductionsWhile returns a sequence of partial results of successively applying the specified combining function to items from the specified sequence while its second return value is true. The first item of the returned sequence will be the first item of the specified sequence. When the specified sequence is empty, the returned sequence will be empty.

TL;DR: it's Reductions with early return.

func Repeat

func Repeat[Item any](item Item) Seq[Item]

Repeat returns a sequence infinitely repeating the specified value.

func RepeatN

func RepeatN[Item any](item Item, n int) Seq[Item]

RepeatN returns a sequence repeating the specified item [n] times.

func Singleton added in v1.0.0

func Singleton[Item any](item Item) Seq[Item]

Singleton returns a singleton sequence containing the specified item.

func Sums

func Sums[Item Summable](seq Seq[Item]) Seq[Item]

Sums returns a sequence of partial sums of items in the specified sequence.

func Take

func Take[Item any](seq Seq[Item], n int) Seq[Item]

Take returns a sequence of at most n items from the start of the specified sequence.

func TakeWhile

func TakeWhile[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]

TakeWhile returns a prefix of the specified sequence that contains only items that match the specified predicate.

func Unfold

func Unfold[Item, State any](seed State, next func(State) (Item, bool, State)) Seq[Item]

Unfold returns a sequence of items generated by successively applying the specified function to the seed value.

The specified function should return three values: * the next item when there is one OR the zero value of [Item] when there isn't * whether there is a next item * the seed value for the next invocation of the function.

func ZipMany

func ZipMany[Item any](seqs ...Seq[Item]) Seq[[]Item]

ZipMany returns a sequence of slices obtained by taking corresponding items from the specified sequences.

type Seq2

type Seq2[K, V any] = iter.Seq2[K, V]

func Bimap

func Bimap[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](
	seq Seq2[ItemIn1, ItemIn2], mapFn1 func(ItemIn1) ItemOut1, mapFn2 func(ItemIn2) ItemOut2,
) Seq2[ItemOut1, ItemOut2]

Bimap returns a sequence of pairs where each value in the pair is the result of applying the two supplied functions to the respective values of a pair from the specified sequence.

func Cartesian

func Cartesian[Item1, Item2 any](seq1 Seq[Item1], seq2 Seq[Item2]) Seq2[Item1, Item2]

Cartesian returns a sequence of pairs where each pair is a member of the cartesian product of (i.e. all combinations of items from) the two specified sequences.

func Concat2

func Concat2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) Seq2[Item1, Item2]

Concat2 returns a sequence of pairs that is the concatenation of pairs from the specified sequences.

func Cycle2

func Cycle2[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item1, Item2]

Cycle2 returns a sequence of pairs that infinitely repeates the specified sequence.

func Drop2 added in v1.0.0

func Drop2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]

Drop2 returns a sequence with at most n pairs dropped from the start of the specified sequence.

func DropLast2 added in v1.0.0

func DropLast2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]

DropLast2 returns the specified sequence of pairs without its last n pairs. When the specified sequence has less than n pairs, the result will be empty.

Uses O(n) space.

func DropWhile2 added in v1.0.0

func DropWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]

DropWhile2 returns the rest of the specified sequence after the prefix of pairs matching the specified predicate.

func Enumerate

func Enumerate[Item any](seq Seq[Item]) Seq2[int, Item]

Enumerate returns a sequence of pairs where each pair consists of the ordinal of an item from the specified sequence and the item itself.

func Filter2

func Filter2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]

Filter2 returns a sequence of pairs that only contains pairs of the specified sequence that match the specified predicate.

func FilterMap2

func FilterMap2[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](
	seq Seq2[ItemIn1, ItemIn2], mapFn func(ItemIn1, ItemIn2) (ItemOut1, ItemOut2, bool),
) Seq2[ItemOut1, ItemOut2]

FilterMap2 returns a sequence that only contains transformed pairs of the specified sequence where the specified function returned true.

func Flatten2

func Flatten2[Item1, Item2 any](seqs Seq[Seq2[Item1, Item2]]) Seq2[Item1, Item2]

Flatten2 returns the concatenation of sequences inside the specified sequence.

func Generate2 added in v1.0.0

func Generate2[Item1, Item2 any](next func() (Item1, Item2)) Seq2[Item1, Item2]

Generate returns a sequence of pairs obtained by calling the specified function repeatedly.

func GenerateWhile2 added in v1.0.0

func GenerateWhile2[Item1, Item2 any](next func() (Item1, Item2, bool)) Seq2[Item1, Item2]

Generate returns a sequence of pairs obtained by calling the specified function repeatedly until it returns false.

The pair returned with false will not be yielded.

func Inspect2 added in v1.0.0

func Inspect2[Item1, Item2 any](seq Seq2[Item1, Item2], observe func(Item1, Item2)) Seq2[Item1, Item2]

Inspect2 returns a sequence whose pairs are the same as the specified sequence's but are passed to the specified function before being yielded.

func Interleave2

func Interleave2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) Seq2[Item1, Item2]

Interleave returns a sequence of pairs obtained by cycling between the specified sequences for each pair. When any of the input sequences is exhausted the sequence ends.

func Intersperse2 added in v1.0.0

func Intersperse2[Item1, Item2 any](seq Seq2[Item1, Item2], sep1 Item1, sep2 Item2) Seq2[Item1, Item2]

Intersperse2 returns a sequence of pairs where separators are inserted between pairs from the specified sequence.

func Map2

func Map2[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](
	seq Seq2[ItemIn1, ItemIn2], mapFn func(ItemIn1, ItemIn2) (ItemOut1, ItemOut2),
) Seq2[ItemOut1, ItemOut2]

Map returns a sequence of pairs obtained by transforming each pair of the specified sequence using the specified function.

func Memoize2

func Memoize2[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item1, Item2]

Memoize2 returns a sequence of pairs that yields memoized pairs from the specified underlying sequence. Each pair of the specified sequence will only be forced at most once.

func Panic2 added in v1.0.0

func Panic2[Item1, Item2 any](reason any) Seq2[Item1, Item2]

Panic2 returns a sequence of pairs that panics with the specified reason when enumerated.

func Reductions2

func Reductions2[Item1, Item2 any](seq Seq2[Item1, Item2], combine func(Item1, Item2, Item1, Item2) (Item1, Item2)) Seq2[Item1, Item2]

Reductions2 returns a sequence of partial results of successively applying the specified combining function to pairs from the specified sequence. The first pair of the returned sequence will be the first pair of the specified sequence. When the specified sequence is empty, the returned sequence will be empty.

func ReductionsWhile2 added in v1.0.0

func ReductionsWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], combine func(Item1, Item2, Item1, Item2) (Item1, Item2, bool)) Seq2[Item1, Item2]

ReductionsWhile2 returns a sequence of partial results of successively applying the specified combining function to pairs from the specified sequence while its third return value is true. The first pair of the returned sequence will be the first pair of the specified sequence. When the specified sequence is empty, the returned sequence will be empty.

TL;DR: it's Reductions2 with early return.

func Repeat2

func Repeat2[Item1, Item2 any](item1 Item1, item2 Item2) Seq2[Item1, Item2]

Repeat2 returns a sequence infinitely repeating the specified pair of values.

func RepeatN2

func RepeatN2[Item1, Item2 any](item1 Item1, item2 Item2, n int) Seq2[Item1, Item2]

RepeatN2 returns a sequence repeating the specified pair of values [n] times.

func Singleton2 added in v1.0.0

func Singleton2[Item1, Item2 any](item1 Item1, item2 Item2) Seq2[Item1, Item2]

Singleton2 returns a singleton sequence containing the specified pair.

func Swap

func Swap[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item2, Item1]

Swap returns a sequence of pairs of the swapped pairs of the specified sequence.

func Take2

func Take2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]

Take2 returns a sequence of at most n pairs from the start of the specified sequence.

func TakeWhile2

func TakeWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]

TakeWhile2 returns a prefix of the specified sequence that contains only pairs that match the specified predicate.

func Unfold2

func Unfold2[Item1, Item2, State any](seed State, next func(State) (Item1, Item2, bool, State)) Seq2[Item1, Item2]

Unfold returns a sequence of pairs generated by successively applying the specified function to the seed value.

The specified function should return four values: * the next first item of the pair when there is one OR the zero value of [Item1] when there isn't * the next second item of the pair when there is one OR the zero value of [Item2] when there isn't * whether there is a next pair of values * the seed value for the next invocation of the function.

func UnpackMap

func UnpackMap[ItemIn, ItemOut1, ItemOut2 any](seq Seq[ItemIn], unpack func(ItemIn) (ItemOut1, ItemOut2)) Seq2[ItemOut1, ItemOut2]

UnpackMap returns a sequence of pairs by unpacking each of the items of the specified sequence to a pair of values.

func Zip

func Zip[Item1, Item2 any](seq1 Seq[Item1], seq2 Seq[Item2]) Seq2[Item1, Item2]

Zip returns a sequence of pairs obtained by taking corresponding items from the specified sequences.

type Summable

type Summable = internal.Summable

Jump to

Keyboard shortcuts

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