Documentation
¶
Index ¶
- func All[Item any](seq Seq[Item], pred Pred[Item]) bool
- func All2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) bool
- func And(seq Seq[bool]) bool
- func Any[Item any](seq Seq[Item], pred Pred[Item]) bool
- func Any2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) bool
- func Empty[Item any](yield func(Item) bool)
- func Empty2[Item1, Item2 any](yield func(Item1, Item2) bool)
- func EmptyMux2[Item1, Item2 any](yield1 func(Item1) bool, yield2 func(Item2) bool)
- func EmptyMux3[Item1, Item2, Item3 any](yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool)
- func EmptyMux4[Item1, Item2, Item3, Item4 any](yield1 func(Item1) bool, yield2 func(Item2) bool, yield3 func(Item3) bool, ...)
- func First[Item any](seq Seq[Item]) (Item, bool)
- func First2[Item1, Item2 any](seq Seq2[Item1, Item2]) (Item1, Item2, bool)
- func Fold[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) Result) Result
- func Fold2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) Result) Result
- func FoldWhile[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) (Result, bool)) Result
- func FoldWhile2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, ...) Result
- func IsEmpty[Item any](seq Seq[Item]) bool
- func IsEmpty2[Item1, Item2 any](seq Seq2[Item1, Item2]) bool
- func Last[Item any](seq Seq[Item]) (last Item, hasLast bool)
- func Last2[Item1, Item2 any](seq Seq2[Item1, Item2]) (last1 Item1, last2 Item2, hasLast bool)
- func Len[Item any](seq Seq[Item]) (cnt int)
- func Len2[Item1, Item2 any](seq Seq2[Item1, Item2]) (cnt int)
- func Max[Item cmp.Ordered](seq Seq[Item]) Item
- func Min[Item cmp.Ordered](seq Seq[Item]) Item
- func Or(seq Seq[bool]) bool
- func Pull[V any](seq Seq[V]) (next func() (V, bool), stop func())
- func Pull2[K, V any](seq Seq2[K, V]) (next func() (K, V, bool), stop func())
- func PullMany[Item any](seqs ...Seq[Item]) (next func() ([]Item, bool), stop func())
- func PullMany2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) (next func() ([]Item1, []Item2, bool), stop func())
- func Reduce[Item any](seq Seq[Item], combine func(Item, Item) Item) (res Item)
- func Reduce2[Item1, Item2 any](seq Seq2[Item1, Item2], ...) (res1 Item1, res2 Item2)
- func ReduceWhile[Item any](seq Seq[Item], combine func(Item, Item) (Item, bool)) Item
- func ReduceWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], ...) (Item1, Item2)
- func Sum[Item Summable](seq Seq[Item]) Item
- func Unzip[Item1, Item2 any](seq Seq2[Item1, Item2]) (Seq[Item1], Seq[Item2])
- func YieldAll[Item any](seq Seq[Item], yield func(Item) bool) bool
- func YieldAll2[Item1, Item2 any](seq Seq2[Item1, Item2], yield func(Item1, Item2) bool) bool
- type MuxSeq2
- type MuxSeq3
- type MuxSeq4
- type Pred
- type Pred2
- type Seq
- func Concat[Item any](seqs ...Seq[Item]) Seq[Item]
- func Count[Item Summable](from Item, step Item) Seq[Item]
- func Cycle[Item any](seq Seq[Item]) Seq[Item]
- func Divvy[Item any](seq Seq[Item], size int, skip int) Seq[[]Item]
- func DivvyExact[Item any](seq Seq[Item], size int, skip int) Seq[[]Item]
- func Drop[Item any](seq Seq[Item], n int) Seq[Item]
- func DropLast[Item any](seq Seq[Item], n int) Seq[Item]
- func DropWhile[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]
- func Filter[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]
- func FilterMap[ItemIn, ItemOut any](seq Seq[ItemIn], mapFn func(ItemIn) (ItemOut, bool)) Seq[ItemOut]
- func Flatten[Item any](seqs Seq[Seq[Item]]) Seq[Item]
- func Folds[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) Result) Seq[Result]
- func Folds2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, combine func(Result, Item1, Item2) Result) Seq[Result]
- func FoldsWhile[Item, Result any](seq Seq[Item], seed Result, combine func(Result, Item) (Result, bool)) Seq[Result]
- func FoldsWhile2[Item1, Item2, Result any](seq Seq2[Item1, Item2], seed Result, ...) Seq[Result]
- func FromValues[Item any](values ...Item) Seq[Item]
- func Generate[Item any](next func() Item) Seq[Item]
- func GenerateWhile[Item any](next func() (Item, bool)) Seq[Item]
- func Inspect[Item any](seq Seq[Item], observe func(Item)) Seq[Item]
- func Interleave[Item any](seqs ...Seq[Item]) Seq[Item]
- func Intersperse[Item any](seq Seq[Item], sep Item) Seq[Item]
- func Map[ItemIn, ItemOut any](seq Seq[ItemIn], mapFn func(ItemIn) ItemOut) Seq[ItemOut]
- func Memoize[Item any](seq Seq[Item]) Seq[Item]
- func MuxMap2[ItemIn1, ItemIn2, ItemOut any](seq MuxSeq2[ItemIn1, ItemIn2], mux1 func(ItemIn1) ItemOut, ...) Seq[ItemOut]
- func MuxMap3[ItemIn1, ItemIn2, ItemIn3, ItemOut any](seq MuxSeq3[ItemIn1, ItemIn2, ItemIn3], mux1 func(ItemIn1) ItemOut, ...) Seq[ItemOut]
- func MuxMap4[ItemIn1, ItemIn2, ItemIn3, ItemIn4, ItemOut any](seq MuxSeq4[ItemIn1, ItemIn2, ItemIn3, ItemIn4], mux1 func(ItemIn1) ItemOut, ...) Seq[ItemOut]
- func PackMap[ItemIn1, ItemIn2, ItemOut any](seq Seq2[ItemIn1, ItemIn2], pack func(ItemIn1, ItemIn2) ItemOut) Seq[ItemOut]
- func Panic[Item any](reason any) Seq[Item]
- func Reductions[Item any](seq Seq[Item], combine func(Item, Item) Item) Seq[Item]
- func ReductionsWhile[Item any](seq Seq[Item], combine func(Item, Item) (Item, bool)) Seq[Item]
- func Repeat[Item any](item Item) Seq[Item]
- func RepeatN[Item any](item Item, n int) Seq[Item]
- func Singleton[Item any](item Item) Seq[Item]
- func Sums[Item Summable](seq Seq[Item]) Seq[Item]
- func Take[Item any](seq Seq[Item], n int) Seq[Item]
- func TakeWhile[Item any](seq Seq[Item], pred Pred[Item]) Seq[Item]
- func Unfold[Item, State any](seed State, next func(State) (Item, bool, State)) Seq[Item]
- func ZipMany[Item any](seqs ...Seq[Item]) Seq[[]Item]
- type Seq2
- func Bimap[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](seq Seq2[ItemIn1, ItemIn2], mapFn1 func(ItemIn1) ItemOut1, ...) Seq2[ItemOut1, ItemOut2]
- func Cartesian[Item1, Item2 any](seq1 Seq[Item1], seq2 Seq[Item2]) Seq2[Item1, Item2]
- func Concat2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) Seq2[Item1, Item2]
- func Cycle2[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item1, Item2]
- func Drop2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]
- func DropLast2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]
- func DropWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]
- func Enumerate[Item any](seq Seq[Item]) Seq2[int, Item]
- func Filter2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]
- func FilterMap2[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](seq Seq2[ItemIn1, ItemIn2], ...) Seq2[ItemOut1, ItemOut2]
- func Flatten2[Item1, Item2 any](seqs Seq[Seq2[Item1, Item2]]) Seq2[Item1, Item2]
- func Generate2[Item1, Item2 any](next func() (Item1, Item2)) Seq2[Item1, Item2]
- func GenerateWhile2[Item1, Item2 any](next func() (Item1, Item2, bool)) Seq2[Item1, Item2]
- func Inspect2[Item1, Item2 any](seq Seq2[Item1, Item2], observe func(Item1, Item2)) Seq2[Item1, Item2]
- func Interleave2[Item1, Item2 any](seqs ...Seq2[Item1, Item2]) Seq2[Item1, Item2]
- func Intersperse2[Item1, Item2 any](seq Seq2[Item1, Item2], sep1 Item1, sep2 Item2) Seq2[Item1, Item2]
- func Map2[ItemIn1, ItemIn2, ItemOut1, ItemOut2 any](seq Seq2[ItemIn1, ItemIn2], mapFn func(ItemIn1, ItemIn2) (ItemOut1, ItemOut2)) Seq2[ItemOut1, ItemOut2]
- func Memoize2[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item1, Item2]
- func Panic2[Item1, Item2 any](reason any) Seq2[Item1, Item2]
- func Reductions2[Item1, Item2 any](seq Seq2[Item1, Item2], ...) Seq2[Item1, Item2]
- func ReductionsWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], ...) Seq2[Item1, Item2]
- func Repeat2[Item1, Item2 any](item1 Item1, item2 Item2) Seq2[Item1, Item2]
- func RepeatN2[Item1, Item2 any](item1 Item1, item2 Item2, n int) Seq2[Item1, Item2]
- func Singleton2[Item1, Item2 any](item1 Item1, item2 Item2) Seq2[Item1, Item2]
- func Swap[Item1, Item2 any](seq Seq2[Item1, Item2]) Seq2[Item2, Item1]
- func Take2[Item1, Item2 any](seq Seq2[Item1, Item2], n int) Seq2[Item1, Item2]
- func TakeWhile2[Item1, Item2 any](seq Seq2[Item1, Item2], pred Pred2[Item1, Item2]) Seq2[Item1, Item2]
- func Unfold2[Item1, Item2, State any](seed State, next func(State) (Item1, Item2, bool, State)) Seq2[Item1, Item2]
- func UnpackMap[ItemIn, ItemOut1, ItemOut2 any](seq Seq[ItemIn], unpack func(ItemIn) (ItemOut1, ItemOut2)) Seq2[ItemOut1, ItemOut2]
- func Zip[Item1, Item2 any](seq1 Seq[Item1], seq2 Seq[Item2]) Seq2[Item1, Item2]
- type Summable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All2 ¶
All2 returns whether the specified predicate matches all pairs in the specified sequence.
func And ¶
And returns the logical AND of the boolean values in the specified sequence. The evaluation is short-circuiting.
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 ¶
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 ¶
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 ¶
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 Last ¶
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 ¶
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 Max ¶ added in v1.0.0
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
Min returns the smallest item in the specified sequence. It returns the zero value for Item when the sequence is empty.
func Or ¶
Or returns the logical OR of the boolean values in the specified sequence. The evaluation is short-circuiting.
func PullMany ¶
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 ¶
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
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 Unzip ¶
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
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.
Types ¶
type MuxSeq2 ¶ added in v1.0.0
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 Seq ¶
func Concat ¶
Concat returns a sequence of items that is the concatenation of items from the specified sequences.
func Count ¶
Count returns a sequence of repeatedly adding step to the previous value, starting with from.
func Divvy ¶
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 ¶
DivvyExact is like Divvy but all yielded slices are exactly size length. Any trailing items are dropped.
func Drop ¶ added in v1.0.0
Drop returns a sequence with at most n items dropped from the start of the specified sequence.
func DropLast ¶ added in v1.0.0
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
DropWhile returns the rest of the specified sequence after the prefix of items matching the specified predicate.
func Filter ¶
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 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 ¶
FromValues returns a sequence that yields the specified values.
func Generate ¶ added in v1.0.0
Generate returns a sequence of items obtained by calling the specified function repeatedly.
func GenerateWhile ¶ added in v1.0.0
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
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 ¶
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
Intersperse returns a sequence of items where separators are inserted between items from the specified sequence.
func Map ¶
Map returns a sequence of items obtained by transforming each item of the specified sequence using the specified function.
func Memoize ¶
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
Panic returns a sequence of items that panics with the specified reason when enumerated.
func Reductions ¶
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
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 Singleton ¶ added in v1.0.0
Singleton returns a singleton sequence containing the specified item.
func TakeWhile ¶
TakeWhile returns a prefix of the specified sequence that contains only items that match the specified predicate.
func Unfold ¶
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.
type Seq2 ¶
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 ¶
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 ¶
Concat2 returns a sequence of pairs that is the concatenation of pairs from the specified sequences.
func Drop2 ¶ added in v1.0.0
Drop2 returns a sequence with at most n pairs dropped from the start of the specified sequence.
func DropLast2 ¶ added in v1.0.0
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 ¶
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 ¶
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 Generate2 ¶ added in v1.0.0
Generate returns a sequence of pairs obtained by calling the specified function repeatedly.
func GenerateWhile2 ¶ added in v1.0.0
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 ¶
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 ¶
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
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 Singleton2 ¶ added in v1.0.0
Singleton2 returns a singleton sequence containing the specified pair.
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.