You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposal is to add functions for traversing several sequences without creating intermediate containers:
// Concat returns an iterator that yields elements of the given sequences in order.funcConcat[Vany](seqs...iter.Seq[V]) iter.Seq[V] {
returnfunc(yieldfunc(V) bool) {
for_, seq:=rangeseqs {
forv:=rangeseq {
if!yield(v) {
return
}
}
}
}
}
// Concat2 returns an iterator that yields elements of the given sequences of pairs in order.funcConcat2[K, Vany](seqs...iter.Seq2[K, V]) iter.Seq2[K, V] {
returnfunc(yieldfunc(K, V) bool) {
for_, seq:=rangeseqs {
fork, v:=rangeseq {
if!yield(k, v) {
return
}
}
}
}
}
Example usage:
funcprint(a, b []int) {
forv:=rangeiter.Concat(slices.Values(a), slices.Values(b)) {
fmt.Println(v)
}
}
The text was updated successfully, but these errors were encountered:
Proposal Details
The proposal is to add functions for traversing several sequences without creating intermediate containers:
Example usage:
The text was updated successfully, but these errors were encountered: