seq

module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: GPL-3.0

README

seq - A Go Iterator Module

Go Reference Go Report Card

A module built around range funcs introduced in Go 1.23. See documentation for usage and examples.

Overview

Most functionality in this package can be roughly grouped into three categories:

  • Producers: Construct an iterator from non-iterator values. Example from the standard library: slices.All.
  • Consumers: Take iterators and condense them into non-iterator values. Example from the standard library: slices.Collect.
  • Transformers: Provide iterators backed by other iterators.

Packages of this module may contain any combination of producers, consumers and transformers.

Iterator properties

Finite vs. Infinite

Some iterators stop yielding items even if the for loop that ranges over them never breaks or returns. Those are called finite iterators. If an iterator produces values as long as for ranges over it, it is called infinite.

Infinite iterators can lead to problems in some situations, e.g. when trying to collect all values from the iterator into a slice.

Reusability

Iterators may yield the same values when ranged over twice. Such iterators are called reusable. Others may yield different values or no values at all.

In seq Module

There is no in-code flag or label to mark iterators as finite/infinite or whether it is reusable. Many iterators are both, e.g. the Filter transformer produces iterators that inherit their properties from the iterator the values are taken from – if its finite, the filtered iterator is finite and so on. In general, the behaviour is documented or can be deduced fairly easily.

Directories

Path Synopsis
Package bigseq handles types of the math/big package in a Go 1.23 iterator way.
Package bigseq handles types of the math/big package in a Go 1.23 iterator way.
Package bitseq applies bitwise operations to sequences of integers.
Package bitseq applies bitwise operations to sequences of integers.
Package boolseq contains helpers for sequences of booleans.
Package boolseq contains helpers for sequences of booleans.
Package combine takes a middleware-like approach for functions that take an iterator and return an iterator, a.k.a.
Package combine takes a middleware-like approach for functions that take an iterator and return an iterator, a.k.a.
internal
Package iterate builds around iter.Seq.
Package iterate builds around iter.Seq.
pred
Package pred contains predicates for iterate's Filter() and While() iterators.
Package pred contains predicates for iterate's Filter() and While() iterators.
Package iterate2 builds around iter.Seq2.
Package iterate2 builds around iter.Seq2.
pred2
Package pred2 contains predicates for iterate2's Filter() and While() iterators.
Package pred2 contains predicates for iterate2's Filter() and While() iterators.
Package mathseq operates on numerical sequences.
Package mathseq operates on numerical sequences.
Package throttle allows for throttling iterators.
Package throttle allows for throttling iterators.
Package ticker provides a sequence based on ticks.
Package ticker provides a sequence based on ticks.

Jump to

Keyboard shortcuts

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