Skip to content

Instantly share code, notes, and snippets.

@jarrodhroberson
Last active February 19, 2025 17:38
Show Gist options
  • Save jarrodhroberson/19d6fc559f9cb1aeb7167686e74529ef to your computer and use it in GitHub Desktop.
Save jarrodhroberson/19d6fc559f9cb1aeb7167686e74529ef to your computer and use it in GitHub Desktop.
iter.Seq/iterSeq2
// Seq is an iterator over sequences of individual values.
// When called as seq(yield), seq calls yield(v) for each value v in the sequence,
// stopping early if yield returns false.
// See the [iter] package documentation for more details.
type Seq[V any] func(yield func(V) bool)
// Seq2 is an iterator over sequences of pairs of values, most commonly key-value pairs.
// When called as seq(yield), seq calls yield(k, v) for each pair (k, v) in the sequence,
// stopping early if yield returns false.
// See the [iter] package documentation for more details.
type Seq2[K, V any] func(yield func(K, V) bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment